因为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
			}

Logo

前往低代码交流专区

更多推荐