微信小程序开发——隐藏且占位

index.wxml

<!--index.wxml-->
<!--页面根标签-->
<view class="content">
	<!--pics文件夹下的background.jpg文件-->
	<image class='background' src="/images/beijing1.jpg" mode="aspectFill"></image>
	<!--页面其它部分-->
</view>

<view class="box">
  <view class="title">货币兑换</view>
  <form bindsubmit="calc" bindreset="reset">
    <input name='cels' placeholder='请输入人民币金额' type='number' auto-focus="true"></input>
    <input name='meihui' placeholder='美元汇率' type='number' auto-focus="true"></input>
    <input name='yinghui' placeholder='英镑汇率' type='number' auto-focus="true"></input>
    <input name='ouhui' placeholder='欧元汇率' type='number' auto-focus="true"></input>
    <input name='rihui' placeholder='日元汇率' type='number' auto-focus="true"></input>
    <view class='btnLayout'>
      <button  form-type="submit" bindtap='reset'>计算</button>		//bindtap='reset'  绑定flag的属性
      <button  form-type="reset" bindtap='abc'>清除</button>	//bindtap='abc'  绑定flag的属性
    </view>
    <view style='{{flag}}' class="textLayout">
      <text>兑换美元为:{{M}}</text>
      <text>兑换英镑为:{{Y}}</text>
      <text>兑换欧元为:{{O}}</text>
      <text>兑换日元为:{{R}}</text>
    </view>
  </form>
</view>

index.js

//index.js
var C,MH,YH,OH,RH;
Page({
  data:{
    flag:"visibility: hidden;"		//设置隐藏且占位
  },
  calc: function (e) {
    C = parseInt(e.detail.value.cels)
    MH= parseInt(e.detail.value.meihui)
    YH= parseInt(e.detail.value.yinghui)
    OH= parseInt(e.detail.value.ouhui)
    RH= parseInt(e.detail.value.rihui)
    this.setData({
      M: (C / MH).toFixed(4),
      Y: (C / YH).toFixed(4),
      O: (C / OH).toFixed(4),
      R: (C / RH).toFixed(4),
    })
  },
  reset: function () {
    this.setData({
      M: '',
      Y: '',
      O: '',
      R: '',  
      flag:""			//取消隐藏
    })
  },
  abc:function () {
      this.setData({
        flag:"visibility: hidden;"		//继续维持隐藏属性
      })
    }
})
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值