vue.js报错 vue.js:597 [Vue warn]: Cannot find element: #app
问题: vue.js:597 [Vue warn]: Cannot find element: #app-4 检查了几遍代码没错,最后发现是引入vue的script必须放在body的末尾行。解决: 引入vue的script必须放在body的末尾行。
------------------------------------------------------------------------------
1.使用vuejs 官网上面的例子,在控制台中发现了错误了,
VM2369 vue.js:2658 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the "name" option. (found in root instance)
此原因是需要先注册组件,然后新建Vue
,顺序不能颠倒
2.源码:
Vue.component('todo-item', {
props: ['todo'],
template: '{{ todo.text }} '
})
var app7 = new Vue({
el: '#app-7',
data: {
groceryList: [
{ text: 'Vegetables' },
{ text: 'Cheese' },
{ text: 'Whatever else humans are supposed to eat' }
]
}
})