我在vue data里声明了一个specIndex的变量,然后我通过for改变specIndex的值,结果只能检测到for最后一次改变值得变化。例如下面的写法,specIndex的值从1变成3,但是只能检测到最后一次specIndex等于3,请问大神我该如何处理,或者有其它方法实现类似的功能! for(var i=0;i<=3;i++){ app.specIndex=i; } app.$watch('specIndex', function (newVal, oldVal) { var select2 = $("#Spec" + newVal).select2({ theme: "classic", placeholder: "请选择规格" }); $(app.specListBox).each(function (i, item) { if (item.index == newVal) { item.select2 = select2; item.select2.on("change", function (e) { var SepcValue = e.target.value; item.SelectedparaValue = []; }); } }); });
添加回答
举报
0/150
提交
取消
