uniapp踩坑之四-----点击当前元素获取本身的text
因为vue的获取方式在uniapp里面不生效,只能另想方法<view class="cityStyle" v-for="(item, index) in cityaddress" @click="isSelect"ref='cityItem' :data-index='index'>{{item.city}}</view>cityaddress:[{city:'湛江',id
·
因为vue的获取方式在uniapp里面不生效,只能另想方法
<view class="cityStyle" v-for="(item, index) in cityaddress" @click="isSelect" ref='cityItem' :data-index='index'>
{{item.city}}
</view>
cityaddress:[
{city:'湛江',
id:'1'},{city:'广州',
id:'2'},{city:'茂名',
id:'3'},{city:'珠海',
id:'4'},{city:'东莞',
id:'5'},{city:'佛山',
id:'6'},
],
isSelect(e){
// console.log(e.currentTarget.dataset.index)
let num = e.currentTarget.dataset.index
console.log(this.cityaddress[num].city)//这个就是获取的值
this.address = this.cityaddress[num].city
this.showPopup = false
}
更多推荐
已为社区贡献2条内容
所有评论(0)