演示效果
.js文件
Page({
data:{
vlist:["深圳","广州","西安","上海","佛山"],
city:"深圳",
show:false
},
ifshow:function(){
var s=this.data.show
this.setData({
show:!s
})
},
cho:function(e){
console.log(e.currentTarget.data.city);
this.setData({
city:e.currentTarget.dataset.city,
show:false
})
},
})
.wxml文件
<view class="" bind:tap="ifshow">
{{city}}
<image src="/image/1.jpg" mode=""/>
</view>
<view class="" wx:if="{{show}}">
<text wx:for="{{vlist}}" bind:tap="cho" data-city="{{item}}">
{{item}}
</text>
</view>