小程序的显示与隐藏切换

最近在做一个集人脸识别、地标识别等功能的小程序,在项目中需要用到内容的显示和隐藏功能。
项目已经上线,下面是小程序码
在这里插入图片描述
现做下总结。
效果图
在这里插入图片描述

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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值