利用三元運(yùn)算符實(shí)現(xiàn)登錄注冊(cè)效果切換,供大家參考,具體內(nèi)容如下
直接上代碼
wxml:
<view class='top'> <text class="{{login?'active':''}}" catchtap='login'>登錄</text> <text class="{{login?'':'active'}}" catchtap='register'>注冊(cè)</text></view> <view class='log' wx:if="{{login}}"> <form> <input placeholder='賬號(hào)'/> <button>登錄</button> </form> </view><view class='reg'wx:else> <form> <input placeholder='密碼'/> <button>注冊(cè)</button> </form></view>wxss:
.top{ display: flex; flex-direction: row; height: 100rpx; border-bottom: 1px solid #ccc;}.top text{ width: 50%; line-height: 100rpx; text-align: center;}.top .active{ border-bottom: 2px solid red;}input{ border-bottom: 1px solid #ccc; line-height: 100rpx; height: 100rpx; padding-left: 40rpx; margin-bottom: 40rpx;}js:
Page({ data: { login:true }, /** * 生命周期函數(shù)--監(jiān)聽頁面加載 */ login:function(){ this.setData({ login:true }); }, register:function(){ this.setData({ login: false }); }, onLoad: function (options) { }, /** * 生命周期函數(shù)--監(jiān)聽頁面初次渲染完成 */ onReady: function () { }, /** * 生命周期函數(shù)--監(jiān)聽頁面顯示 */ onShow: function () { }, /** * 生命周期函數(shù)--監(jiān)聽頁面隱藏 */ onHide: function () { }, /** * 生命周期函數(shù)--監(jiān)聽頁面卸載 */ onUnload: function () { }, /** * 頁面相關(guān)事件處理函數(shù)--監(jiān)聽用戶下拉動(dòng)作 */ onPullDownRefresh: function () { }, /** * 頁面上拉觸底事件的處理函數(shù) */ onReachBottom: function () { }, /** * 用戶點(diǎn)擊右上角分享 */ onShareAppMessage: function () { }})以上就是本文的全部內(nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持VEVB武林網(wǎng)。
新聞熱點(diǎn)
疑難解答
圖片精選