最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

Vue監(jiān)聽一個(gè)數(shù)組id是否與另一個(gè)數(shù)組id相同的方法

 更新時(shí)間:2018年09月26日 10:08:41   作者:DevilLittle  
今天小編就為大家分享一篇Vue監(jiān)聽一個(gè)數(shù)組id是否與另一個(gè)數(shù)組id相同的方法,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧

數(shù)據(jù)list,結(jié)構(gòu)為[{id:1,…},{id:2,…}],數(shù)據(jù)shoplist,結(jié)構(gòu)為[{id:1,…},{id:2,…}],判斷當(dāng)shoplist.id等于list.id時(shí)顯示list的數(shù)據(jù)。

.vue文件:

<template>
 <div class="hello">
 <div class="shoplist">
  <button @click="clickButtonShopList">click me</button>
  <span>shoplist-id:</span><input type="text" v-model="shoplist[shopCount].id">
 </div>
 <div class="list">
  <button @click="clickButtonList">click me</button>
  <span>list-id:</span><input type="text" v-model="list[listCount].id">
 </div>

 <input class="data" v-model="data">

 <h2>{{list}}</h2>
 <h2>{{shoplist}}</h2>
 </div>
</template>

.js文件:

export default {
 data () {
 return {
  msg: 'Welcome to Your Vue.js App',
  shopCount:0,
  listCount:0,
  data:'',
  list:[{id:1,name:'hello'},{id:2,name:'hello'},{id:3,name:'hello'},{id:4,name:'hello'},{id:5,name:'hello'}],
  shoplist:[{id:1,name:'hello'},{id:2,name:'hello'},{id:3,name:'hello'},{id:4,name:'hello'},{id:5,name:'hello'}]
 };
 },
 methods:{
 clickButtonShopList:function () {
  this.shopCount++;
  this.shopCount=this.shopCount%this.shoplist.length;
  this.getData();
 },
 clickButtonList:function () {
  this.listCount++;
  this.listCount=this.listCount%this.list.length;
  this.getData();
 },

 getData:function () {
  this.data='';
  if(this.shoplist[this.shopCount].id===this.list[this.listCount].id){
//  this.data=this.list;
  this.data=this.list.map((element)=>{
   return element.id+element.name;
  }).join(',')
  }else {
  this.data='';
  }
 }
 },
 mounted: function(){
 this.getData();
 }
}

.less文件:

.list{
 margin-top: 20px;
 }

 .data{
 width: 500px;
 height:200px;
 border: 1px solid #666666;
 margin-top: 20px;
 }

效果:

剛開始時(shí):

Vue 監(jiān)聽數(shù)組id

兩邊id不同時(shí):

Vue 監(jiān)聽數(shù)組id

通過點(diǎn)擊使得兩邊id相同時(shí):

Vue 監(jiān)聽數(shù)組id

以上這篇Vue監(jiān)聽一個(gè)數(shù)組id是否與另一個(gè)數(shù)組id相同的方法就是小編分享給大家的全部內(nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。

相關(guān)文章

  • vue2.0 中使用transition實(shí)現(xiàn)動(dòng)畫效果使用心得

    vue2.0 中使用transition實(shí)現(xiàn)動(dòng)畫效果使用心得

    這篇文章主要介紹了vue2.0 中使用transition實(shí)現(xiàn)動(dòng)畫效果使用心得,本文通過案例知識給大家介紹的非常詳細(xì),需要的朋友參考下吧
    2018-08-08
  • 關(guān)于electron-vue打包后運(yùn)行白屏的解決方案

    關(guān)于electron-vue打包后運(yùn)行白屏的解決方案

    這篇文章主要介紹了關(guān)于electron-vue打包后運(yùn)行白屏的解決方案,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-10-10
  • Proxy中代理數(shù)據(jù)攔截的方法詳解

    Proxy中代理數(shù)據(jù)攔截的方法詳解

    這篇文章主要為大家詳細(xì)介紹了Proxy中代理數(shù)據(jù)攔截的方法,文中的示例代碼講解詳細(xì),對我們學(xué)習(xí)或工作具有一定的借鑒價(jià)值,需要的可以參考一下
    2022-12-12
  • swiper/vue 獲取 swiper實(shí)例方法詳解

    swiper/vue 獲取 swiper實(shí)例方法詳解

    在網(wǎng)上搜了一下如何調(diào)用swiper實(shí)例,大部分都是通過 swiperRef = new Swiper(‘.swiper’, options) 這種方法初始化swiper,然后直接能用 swiperRef 實(shí)例,這篇文章主要介紹了swiper/vue 獲取 swiper實(shí)例方法詳解,需要的朋友可以參考下
    2023-12-12
  • 聊聊Vue中provide/inject的應(yīng)用詳解

    聊聊Vue中provide/inject的應(yīng)用詳解

    這篇文章主要介紹了聊聊Vue中provide/inject的應(yīng)用詳解,文中通過示例代碼介紹的非常詳細(xì),對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2019-11-11
  • 詳解lottie動(dòng)畫在vue中的應(yīng)用

    詳解lottie動(dòng)畫在vue中的應(yīng)用

    Lottie 是一個(gè)適用于 Android、iOS、Web 和 Windows 的庫,它使用 Bodymovin 解析導(dǎo)出為 JSON 的 Adobe After Effects 動(dòng)畫,下面我們就來看看它在vue中的是如何應(yīng)用的吧
    2023-12-12
  • vue中vue-router的使用說明(包括在ssr中的使用)

    vue中vue-router的使用說明(包括在ssr中的使用)

    這篇文章主要介紹了vue中vue-router的使用說明(包括在ssr中的使用),具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2022-05-05
  • Vue $attrs & inheritAttr實(shí)現(xiàn)button禁用效果案例

    Vue $attrs & inheritAttr實(shí)現(xiàn)button禁用效果案例

    這篇文章主要介紹了Vue $attrs & inheritAttr實(shí)現(xiàn)button禁用效果案例,具有很好的參考價(jià)值,希望對大家有所幫助。一起跟隨小編過來看看吧
    2020-12-12
  • 在vue項(xiàng)目中使用Swiper插件詳解

    在vue項(xiàng)目中使用Swiper插件詳解

    這篇文章主要介紹了在vue項(xiàng)目中使用Swiper插件詳解,具有很好的參考價(jià)值,希望對大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教
    2023-01-01
  • 全面詳解vue種數(shù)組去重的12種方法示例

    全面詳解vue種數(shù)組去重的12種方法示例

    這篇文章主要介紹了vue數(shù)組去重的12種方法示例全面詳解,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪
    2023-07-07

最新評論

额济纳旗| 克什克腾旗| 乌审旗| 灵武市| 望谟县| 额济纳旗| 阿克陶县| 克什克腾旗| 平原县| 淮南市| 正定县| 平湖市| 南开区| 城步| 米易县| 方城县| 和硕县| 富民县| 金溪县| 泸水县| 岳阳市| 锡林郭勒盟| 社旗县| 黄平县| 梁河县| 普宁市| 玉田县| 邹平县| 常山县| 桓仁| 祁东县| 晋城| 积石山| 库车县| 犍为县| 聊城市| 蓬莱市| 田林县| 东乌珠穆沁旗| 巫山县| 甘德县|