Vuejs - 无法读取未定义的属性'_withTask' [英] Vuejs - Cannot read property '_withTask' of undefined
问题描述
我试图在按下按钮后使用 v-for
为我的div添加新的html。
但是按下按钮后我得到这个错误,元素(文章)被添加到div一次但之后它将不再起作用。
I am trying to add new html to my div after pressing a button, using v-for
.
But after I press the button I get this error and the element (article) gets added to the div once but after that it won't work anymore.
vue.js ?3de6:1743 TypeError:无法读取属性'_withTask'未定义
移除$ 2(eval at(app.js:561),:7078:13)
at updateListeners( eval at(app.js:561),:2067:7)
在Array.updateDOMListeners(eval at(app.js:561),:7091:3)
at patchVnode(eval at(app.js:561),:5918:62)
at updateChildren(eval at(app.js:561),:5809:9)
at patchVnode(eval at(app.js:561),:5923:29)
at updateChildren(eval at(app.js:561),:5809:9)
at patchVnode(eval at(app.js:561),:5923:29)
at updateChildren(eval at(app.js:561),:5809:9)
at patchVnode(eval at(app.js:561),: 5923:29)
vue.js?3de6:1743 TypeError: Cannot read property '_withTask' of undefined
at remove$2 (eval at (app.js:561), :7078:13)
at updateListeners (eval at (app.js:561), :2067:7)
at Array.updateDOMListeners (eval at (app.js:561),:7091:3)
at patchVnode (eval at (app.js:561), :5918:62)
at updateChildren (eval at (app.js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
at updateChildren (eval at (app.js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
at updateChildren (eval at (app.js:561), :5809:9)
at patchVnode (eval at (app.js:561), :5923:29)
HTML代码:
<article v-for="item in range">
<span>
{{item[0]}} - {{item[1]}}
</span>
<span>
<button class="btn btn-theme btn-default btn-xs pull-left" @click="deleteItem" ><i class="fa fa-times inline"></i></button>
</span>
</article>
JS:
data() {
return {
majornew:this.major,
certificate:this.cert,
range:[],
item:[],
};
},
methods: {
addmajorcert(majortext,certext) {
this.item = [majortext,certext];
this.range.push(this.item);
console.log(majortext,certext);
},
},
更新:有两个选择值发送的方框
<v-select v-model="selectedmajor" label="major_text" id="major" name="majornew" :options="majornew" >
</v-select>
<v-select v-model="selectedcert" :options="certificate" label="lc_text" id="cert" v-on:click="certificate"></v-select>
<button v-on:click="addmajorcert(selectedmajor,selectedcert)">
+
</button>
选择框返回如下对象:
{ "major_id": 2, "major_text": "industrial", "number_of_used": 1 }
当我执行 console.log
时,我可以看到传递的值。
When I do a console.log
I can see the values being passed.
推荐答案
这是我的尝试,
here is my try,
告诉我是否有什么你不理解或我错过了什么。
Tell me if there is something that you do not understand or if I miss something.
这篇关于Vuejs - 无法读取未定义的属性'_withTask'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!