vue.js: [Vue warn]: Unknown custom element: - did you register the component correctly?
2074 ワード
私の元の間違いは:vue.js:634 [Vue warn]: Unknown custom element: - did you register the component correctly? For recursive components, make sure to provide the “name” option. ソース:
エラーの原因:HTMLのラベル名は大文字と小文字が敏感ではないため、ブラウザはすべての大文字を小文字として解釈します.これは、DOMのテンプレートを使用する場合、アルパカネーミング法のprop名を使用するには、等価な短い横線でネーミング方法を区切るか、すべて小文字を使用する必要があることを意味します.否定者は上記のエラーを報告します.
修正後のコード:
parent
//
const introduce = {
//
template: "<h1>{{title}}</h1>",
props: ['title']
};
const forComponent = {
template: "<ul><li v-for='item in items'>{{item}}</li></ul>",
props: ['items']
};
new Vue({
el: "#app",//element vue el
data: {
msg: "hello everyone !",
lessons: ["java", "php","python"],
},
components:{
introduce,
forComponent:forComponent,
}
});
エラーの原因:HTMLのラベル名は大文字と小文字が敏感ではないため、ブラウザはすべての大文字を小文字として解釈します.これは、DOMのテンプレートを使用する場合、アルパカネーミング法のprop名を使用するには、等価な短い横線でネーミング方法を区切るか、すべて小文字を使用する必要があることを意味します.否定者は上記のエラーを報告します.
修正後のコード:
parent
//
const introduce = {
//
template: "<h1>{{title}}</h1>",
props: ['title']
};
const study = {
template: "<ul><li v-for='item in items'>{{item}}</li></ul>",
props: ['items']
};
new Vue({
el: "#app",//element vue el
data: {
msg: "hello everyone !",
lessons: ["java", "php","python"],
},
components:{
introduce,
study:study,
}
});