码迷,mamicode.com
首页 > Web开发 > 详细

Vue.js根据列表某列值更新filter

时间:2017-12-27 14:21:14      阅读:630      评论:0      收藏:0      [点我收藏+]

标签:var   fun   pos   jquer   name   ref   doctype   ext   put   



<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <title></title> <script src="../Scripts/jquery-1.10.2.min.js"></script> </head> <body> <div id="matchList" > <input type="button" value="刷新" onclick="refesh()" /> <div v-for="(item,index) in eventList":id="item.id"> {{item.name}} </div> </div> <script src="https://cdn.bootcss.com/vue/2.4.2/vue.min.js"></script> <script type="text/javascript"> var data = [{ "id": "1", "name": "hh1" }, { "id": "2", "name": "hh2" }, { "id": "3", "name": "hh3" }]; var vm = null; vm=new Vue({ el: "#matchList", data: { eventList: data } }); var eventNum = -1; function refesh() { data = [{ "id": "1", "name": "hh11" }]; //vm.eventList = data; for (var i = 0; i < data.length; i++) { var name = data[i].name; var id = data[i].id; var item = $(vm.eventList).filter(function (index, item) { if (item.id == id) { eventNum = index; } }); if (eventNum > -1) { console.log(eventNum); vm.eventList[eventNum] = data[i]; console.log(vm.eventList[0]); } } //vm.eventList[0] = data[0]; vm.$set(vm.eventList, 0, vm.eventList[0]); } </script> </body> </html>

 

Vue.js根据列表某列值更新filter

标签:var   fun   pos   jquer   name   ref   doctype   ext   put   

原文地址:https://www.cnblogs.com/honghong75042/p/8124809.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!