微信小程序同一界面两个版块的跳转

在同一界面中实现两个版块的跳转,先上图:
在这里插入图片描述
登录界面
在这里插入图片描述
注册界面
wxml代码

<view class="top-line-button {{TopIndex == 0 ? 'active':''}} " data-index="0" bindtap='changstyle'>登陆
    </view>    
    <view class="top-line-button {{TopIndex == 1 ? 'active':''}} " data-index="1" bindtap='changstyle'>注册

js代码

  changstyle:function(e){
   let index=e.currentTarget.dataset.index;
   this.setData({
     TopIndex:index
   })
 },

wxml中由data-index进行点击传值,让js知道你的点击,从而改变 TopIndex的值,来展现不同的界面,下面的界面你就可以这么实现。在这里插入图片描述
对于点击时展现文字不同大小和颜色是通过wxss实现的。

.top-line-button {  
  font-size: 24rpx;     
  color: #777;  
  margin: 150rpx; 
  margin-top:40rpx; 
  padding-top:0rpx;
  } 
.active {                        
   transform: scale(1.45);  
   transform: all 2s;  
   border-bottom-style: solid;  
   border-bottom-color: #744646;  
   border-bottom-width: 5rpx;  
   color: white;
   }
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值