2018-10-27 03:44:50 +08:00
|
|
|
# @vue/server-renderer
|
2020-02-19 03:56:18 +08:00
|
|
|
|
|
|
|
``` js
|
|
|
|
const { createSSRApp } = require('vue')
|
|
|
|
const { renderToString } = require('@vue/server-renderer')
|
|
|
|
|
|
|
|
const app = createSSRApp({
|
|
|
|
data: () => ({ msg: 'hello' }),
|
|
|
|
template: `<div>{{ msg }}</div>`
|
|
|
|
})
|
|
|
|
|
|
|
|
;(async () => {
|
|
|
|
const html = await renderToString(app)
|
|
|
|
console.log(html)
|
|
|
|
})()
|
|
|
|
```
|