最近在做一个集人脸识别、地标识别等功能的小程序,在项目中需要用到内容的显示和隐藏功能。
项目已经上线,下面是小程序码
现做下总结。
效果图
js代码实现
data: {
address:'悉尼歌剧院',
show:false,
url:'../../images/address-one.jpg',
up:'../../images/up.png',
down:'../../images/down.png'
},
//简介显示和隐藏
onVisibility:function(word){
that = this;
that.setData({
show: that.data.show ? false : true
})
},
wxml代码
<text>地标简介(国内)</text>
<image src="{{show == true ? up : down}}" catchtap="onVisibility"></image>
<view class="detail-bottom" wx:if="{{show}}">
<text>地标名称: {{detail.name}}</text>
<text decode="true">简介: {{detail.content}}</text>
<text>位置: {{detail.province}} · {{detail.city}}</text>
</view>
本项目全部代码已上传到GitHub https://github.com/jp9988/Fun—WeChat-applet