微信小程序?qū)崙?zhàn)之登錄頁面制作(5)
提供一個登錄頁的案例,供同學(xué)們使用
項目效果圖:
目錄結(jié)構(gòu):
圖片資源:
name.png
key.png
loginLog.jpg
login.wxml:
<view class="container"> <view class="login-icon"> <image class="login-img" src="../images/loginLog.jpg"></image> </view> <view class="login-from"> <!--賬號--> <view class="inputView"> <image class="nameImage" src="../images/name.png"></image> <label class="loginLab">賬號</label> <input class="inputText" placeholder="請輸入賬號" bindinput="phoneInput" /> </view> <view class="line"></view> <!--密碼--> <view class="inputView"> <image class="keyImage" src="../images/key.png"></image> <label class="loginLab">密碼</label> <input class="inputText" password="true" placeholder="請輸入密碼" bindinput="passwordInput" /> </view> <!--按鈕--> <view class="loginBtnView"> <button class="loginBtn" type="primary" size="{{primarySize}}" loading="{{loading}}" plain="{{plain}}" disabled="{{disabled}}" bindtap="login">登錄</button> </view> </view> </view>
login.wxss:
page{ height: 100%; } .container { height: 100%; display: flex; flex-direction: column; padding: 0; box-sizing: border-box; background-color: #f2f2f2 } /*登錄圖片*/ .login-icon{ flex: none; } .login-img{ width: 750rpx; } /*表單內(nèi)容*/ .login-from { margin-top: 20px; flex: auto; height:100%; } .inputView { background-color: #fff; line-height: 44px; } /*輸入框*/ .nameImage, .keyImage { margin-left: 22px; width: 14px; height: 14px } .loginLab { margin: 15px 15px 15px 10px; color: #545454; font-size: 14px } .inputText { flex: block; float: right; text-align: right; margin-right: 22px; margin-top: 11px; color: #cccccc; font-size: 14px } .line { width: 100%; height: 1px; background-color: #cccccc; margin-top: 1px; } /*按鈕*/ .loginBtnView { width: 100%; height: auto; background-color: #f2f2f2; margin-top: 0px; margin-bottom: 0px; padding-bottom: 0px; } .loginBtn { width: 80%; margin-top: 35px; }
login.js:
Page({ data: { phone: '', password:'' }, // 獲取輸入賬號 phoneInput :function (e) { this.setData({ phone:e.detail.value }) }, // 獲取輸入密碼 passwordInput :function (e) { this.setData({ password:e.detail.value }) }, // 登錄 login: function () { if(this.data.phone.length == 0 || this.data.password.length == 0){ wx.showToast({ title: '用戶名和密碼不能為空', icon: 'loading', duration: 2000 }) }else { // 這里修改成跳轉(zhuǎn)的頁面 wx.showToast({ title: '登錄成功', icon: 'success', duration: 2000 }) } } })
運行結(jié)果:
為大家推薦現(xiàn)在關(guān)注度比較高的微信小程序教程一篇:《微信小程序開發(fā)教程》小編為大家精心整理的,希望喜歡。
以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。
相關(guān)文章
使用Promise鏈?zhǔn)秸{(diào)用解決多個異步回調(diào)的問題
這篇文章主要給大家介紹了使用Promise鏈?zhǔn)秸{(diào)用解決多個異步回調(diào)問題的方法,文中給出了詳細(xì)的介紹和示例代碼,有需要的朋友可以參考借鑒,下面來一起學(xué)習(xí)學(xué)習(xí)吧。2017-01-01如何利用 JS 腳本實現(xiàn)網(wǎng)頁全自動秒殺搶購功能
這篇文章主要介紹了如何利用 JS 腳本實現(xiàn)網(wǎng)頁全自動秒殺搶購功能,本文通過實例代碼給大家介紹的非常詳細(xì),對大家的學(xué)習(xí)或工作具有一定的參考借鑒價值,需要的朋友可以參考下2020-10-10關(guān)于js復(fù)制內(nèi)容到瀏覽器剪貼板報錯:Cannot read properties of&n
這篇文章主要給大家介紹了關(guān)于js復(fù)制內(nèi)容到瀏覽器剪貼板報錯:Cannot read properties of undefined (reading ‘writeText‘)的解決方案,文中給出了詳細(xì)的原因分析和解決方案,需要的朋友可以參考下2024-01-01