我有以下問題,由于某種原因,v-for根本不會呈現。請在這里找到小提琴,https://jsfiddle.net/tadeyemi/k6s4gv85/ 我完全不知道為什么它不起作用。有人在乎透露一些線索嗎?<div id="app"> <h1>Finds</h1> <div> <input ref="option"> </div> <button v-if @click="addFind"> New Find </button> <p v-for="(option,idx) in options.slice(1)"> <span @click="removeOption(idx+1)">Option{{idx+1}}: {{option}}</span> </p></div>和 JavaScript,如下所示:new Vue({ el: '#app', data: { options: [], count:0 }, methods: { addFind: function () { var msg = this.$refs.option.value; console.log(this.options); if( msg.trim() != "" ){ this.count++; var i = this.count; this.options[i]= this.$refs.option.value.trim(); } }, removeOption:function(index){ this.options.splice(index,1); this.count--; } }});
Vue.js v-for not rendering component
米脂
2022-08-18 16:35:04