VueJs - V-for 渲染失败 属性 或未定义方法
VueJs - V-for Render fail property or method is not defined
我遇到了一个奇怪的错误,但我找不到它发生的原因。
我正在尝试在我的 blade 视图中创建一个 v-for
,但我收到了这条消息:
"[Vue warn]: Property or method "question" is not defined on the instance but referenced during render(...)" And then my page won't render
但是"question"只是我的v-for
别名!这是我的代码:
Blade 视图:
<section class="clearfix section--faq vue--faq">
<ul class="faq__list list--faq">
<li v-for"(question,index) in questions" :key="index" class="faq__item card">
<article class="faq__article">
<h3 class="title--faq">
@{{question.titre}}
</h3>
<p class="faq__answer">
@{{question.reponse}}
</p>
</article>
</li>
</ul>
</section>
VueJS:
if( $('.vue--faq').length ){
var faq = new Vue({
el: '.vue--faq',
data:{
faqCategories:'',
questions :'',
baseUrl : $(".baseurl").text(),
},
mounted : function(){
this.getQuestions();
this.getCategories();
},
methods:{
getCategories : function(){
var self = this;
var response = axios.get(self.baseUrl+"/api/faqs/categories")
.then(function(response){
self.faqCategories = response.data;
});
},
getQuestions : function(){
var self = this;
var response = axios.get(self.baseUrl+"/api/faqs/index")
.then(function(response){
self.questions = response.data;
});
},
},
});
};
知道为什么会这样吗?我从来没有遇到过为什么 v-for
和 ajax
之前打电话给...
v-for
之后缺少 =
。放入 =
修复它!
我遇到了一个奇怪的错误,但我找不到它发生的原因。
我正在尝试在我的 blade 视图中创建一个 v-for
,但我收到了这条消息:
"[Vue warn]: Property or method "question" is not defined on the instance but referenced during render(...)" And then my page won't render
但是"question"只是我的v-for
别名!这是我的代码:
Blade 视图:
<section class="clearfix section--faq vue--faq">
<ul class="faq__list list--faq">
<li v-for"(question,index) in questions" :key="index" class="faq__item card">
<article class="faq__article">
<h3 class="title--faq">
@{{question.titre}}
</h3>
<p class="faq__answer">
@{{question.reponse}}
</p>
</article>
</li>
</ul>
</section>
VueJS:
if( $('.vue--faq').length ){
var faq = new Vue({
el: '.vue--faq',
data:{
faqCategories:'',
questions :'',
baseUrl : $(".baseurl").text(),
},
mounted : function(){
this.getQuestions();
this.getCategories();
},
methods:{
getCategories : function(){
var self = this;
var response = axios.get(self.baseUrl+"/api/faqs/categories")
.then(function(response){
self.faqCategories = response.data;
});
},
getQuestions : function(){
var self = this;
var response = axios.get(self.baseUrl+"/api/faqs/index")
.then(function(response){
self.questions = response.data;
});
},
},
});
};
知道为什么会这样吗?我从来没有遇到过为什么 v-for
和 ajax
之前打电话给...
v-for
之后缺少 =
。放入 =
修复它!