多应用+插件架构,代码干净,二开方便,首家独创一键云编译技术,文档视频完善,免费商用码云13.8K 广告
## 事件绑定 [TOC] >[info] #### 循环绑定事件获取ID ~~~ <div id="myId"> <li v-for="item in items" @click="add(item)"> <p class="fri_p"> <img :src="item.img_src" alt=""/> <span>@{{item.user_name}}</span> <b class="fl_adF1"><i></i><em></em></b> </p> </li> </div> //add方法里的item就是v-for里的item ~~~ ~~~ var list = rev.data.list; var listVue = new Vue({ el: "#myId" , data: { items: list } ,methods:{ add:function (event) { console.log(event.user_id); } } }); ~~~ >[info] #### 获取点击当前内容 ~~~ <li v-for="item in items" @click.once="add(item, $event)"> <p class="fri_p"> </p> </li> ~~~ ~~~ ,methods:{ add:function (item, event) { var el = event.currentTarget; console.log(el); } } ~~~ >[info] #### v-for 循环,ajax获取数据动态加载,重新渲染列表 * 首先全局new Vue然后对data赋值 ~~~ var listVue = new Vue({ el: "#myId" , data: { items: {} } , methods: { add: function (item, event) { var el = event.currentTarget; } } }); ~~~ ~~~ function addStranger(page, keywords) { var word = typeof(keywords) === 'undefined' ? '' : keywords; $.post("", {page: page, keywords: word}, function (rev) { if (rev.status === 0) { var list = rev.data.list; page = rev.data.page; listVue.items = list; } }, 'json'); } ~~~