vue-cli3 使用extend遇到错误
前端 /
2018-07-25 /
阅读: 2
vue-cli3 使用extend遇到错误,具体报错内容:
[Vue warn]: You are using the runtime-only build of Vue where the template compiler is not available. Either pre-compile the templates into render functions, or use the compiler-included build.
大意是使用render方法代替template属性,template属性已经不被支持。参照app的渲染方法修改一下就搞定了。
报错的代码:
let ErrorDialog = Vue.extend({
template: '<div>测试</div>'
})
let errorDialog = new ErrorDialog()
let errorMount = errorDialog.$mount()
window.document.body.appendChild(errorMount.$el)修改后的代码:
import test from './components/test'
let ErrorDialog = Vue.extend({
render: h => h(test)
})
let errorDialog = new ErrorDialog()
let errorMount = errorDialog.$mount()
window.document.body.appendChild(errorMount.$el)