【发布时间】:2019-02-14 08:55:37
【问题描述】:
VueJS 新手,正在阅读教程。这是我做的步骤
- 使用 VUE CLI 创建项目
-
尝试使用此代码创建组件。
var data = { items: [{ text: 'Bananas', checked: true }, { text: 'Apples', checked: false } ], title: 'My Shopping List', newItem: '' }; Vue.component('items-component', { data: function () { return data; }, template: ` <div class="blog-post"> <span>sample</span> </div> ` }); -
将此添加到 App.vue 模板部分。
<items-component></items-component>
但是我得到了这个错误
[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.
问题
有没有一种方法可以在一个 Vue Cli 项目中一次性创建多个组件 文件或多个文件是创建组件的唯一方法?。
使用 CLI 手动编辑 webpack 是一个不错的选择吗?如果有,有吗 任何好的链接。
请告诉我
【问题讨论】:
标签: vue.js vuejs2 vue-component vue-loader