-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
46 lines (40 loc) · 838 Bytes
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import express from 'express'
import { createSSRApp } from 'vue'
import { renderToString } from 'vue/server-renderer'
const app = express();
/*mongoose.connect("mongodb://localhost/auth");
const db = mongoose.connection;
db.once("open", () => {
console.log("database is connected");
})
*/
app.get("/", (req, res) => {
const app = createSSRApp({
data: () => ({ count: 'amirreza' }),
template: '<h1 >{{ count }}</h1>',
methods:
{
test()
{
alert(this.count)
}
}
})
renderToString(app).then((html) => {
res.send(`
<!DOCTYPE html>
<html>
<head>
<title>Vue SSR Example</title>
</head>
<body>
<div id="app">
<h1>${html}</h1>
</div>
</body>
</html>
`)
})
});
//app.use("/user", user);
app.listen(4000);