看着那(这 的WebPack-简单 vue-cli模板作为指南,我相信你错过了一个依赖:
https://github.com/vuejs-templates/webpack-simple/blob/master/template/package.json#L26
"vue-template-compiler": "^2.2.1",
如果只有运行时构建,则不能使用template属性,而必须使用render函数或包含模板编译器。
尝试将main.js更改为
import Vue from 'vue' //import App from './app.vue' new Vue({ el: '#app', render: function(createElement) { return createElement( 'p', 'haaaa' ) } })
的jsfiddle 工作小提琴
使用Webpack时 .vue 文件将能够从中编译 <template></template> 标签,但主Vue根必须使用通常看起来像的渲染功能
.vue
<template></template>
import Vue from 'vue' import App from './app.vue' new Vue({ el: '#app', render: function(createElement) { return createElement( App ) } })