Vue.js SSR - 如何要求导入vue-server-renderer?

时间:2017-08-20 17:55:04

标签: node.js ecmascript-6 vue.js vuejs2

我如何要求 vue-server-renderer代替import

const renderer = require('vue-server-renderer').createRenderer()

我试过了:

import renderer from 'vue-server-renderer'
const vueRenderer = renderer.createRenderer()

错误:

var vueRenderer = _vueServerRenderer2.default.createRenderer();
                                             ^
TypeError: Cannot read property 'createRenderer' of undefined

有什么想法吗?

1 个答案:

答案 0 :(得分:2)

createRenderer - 包vue-server-renderer

中的导出功能
import {createRenderer} from 'vue-server-renderer'

const renderer = createRenderer()