共计 1116 个字符,预计需要花费 3 分钟才能阅读完成。
vue.js 2.0 要求每个 template 只能有一个根元素。可以在最外层包一个 div 来解决这个问题。
vue.js:435 [Vue warn]: Error compiling template:
<h2> 这是页头 </h2>
<button> 登录 </button>
Component template should contain exactly one root element. If you are using v-if on multiple elements, use v-else-if to chain them instead.
解决方案:在最外边 包上一个容器(不允许直接返回多个元素)
额
vue.js:435 [Vue warn]: Unknown custom element: <my-footer> – did you register the component correctly? For recursive components, make sure to provide the “name” option.
原因:你把局部组件当成全局组件去使用了
解决方案:
正确的注册组件
3、The “data” option should be a function that returns a per-instance value in component definitions.
原因:在组件中去初始化数据 不允许给 data 直接赋值一个对象
解决方案:Vue.component(”,{
data:function(){
return {}
}
})
4、Uncaught TypeError: Cannot read property ‘push’ of undefined
原因:push 前面的那个变量,其实 undefined
解决方案:
this 通过箭头函数来解决问题
5、ERROR in ./src/assets/img/favicon.icoModule parse failed: C:xampphtdocsframeworkvueprojecttplssrcassetsimgfavicon.ico Unexpected character ” (1:0)You may need an appropriate loader to handle this file type.(Source code omitted for this binary file)
解决方案:找到 build/webpack.base.conf.js 在 41 行加上 |ico
6、No ‘Access-Control-Allow-Origin’ header is present on the requested resource. Origin ‘http://localhost:8080’ is therefore not allowed access.
跨域问题