vue 實(shí)現(xiàn)用戶登錄方式的切換功能
一、vue 實(shí)現(xiàn)用戶登錄方式的切換
在 data 當(dāng)中,定義一個(gè)標(biāo)識(shí)符 loginWay,用來表示是用短信登錄還是密碼登錄,true代表短信登錄,false 代表密碼登錄,代碼如下所示:
data() {
return {
loginWay: true
}
}
在短信登錄和密碼登錄上,進(jìn)行動(dòng)態(tài)樣式綁定,loginWay為true就短信登錄綁定動(dòng)態(tài)樣式on,loginWay為false就密碼登錄綁定動(dòng)態(tài)樣式on,并且也綁定點(diǎn)擊事件,進(jìn)行設(shè)置 loginWay的true和false,代碼如下所示:
<h2 class="login_logo">用戶登錄</h2>
<div class="login_header_title">
<a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" :class="{on: loginWay}" @click="loginWay = true">短信登錄</a>
<a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" :class="{on: !loginWay}" @click="loginWay = false">密碼登錄</a>
</div>
對(duì)于短信登錄和密碼登錄的內(nèi)容,同樣也設(shè)置動(dòng)態(tài)樣式綁定。當(dāng)為loginWay為true 的時(shí)候設(shè)置短信登錄為on,當(dāng)為loginWay為false 的時(shí)候設(shè)置密碼登錄為on,代碼如下所示:
<div :class="{on: loginWay}">
<section class="login_message">
<input type="tel" maxlength="11" placeholder="手機(jī)號(hào)">
<button disabled="disabled" class="get_verification">獲取驗(yàn)證碼</button>
</section>
<section class="login_verification">
<input type="tel" maxlength="8" placeholder="驗(yàn)證碼">
</section>
<section class="login_hint">
溫馨提示:未注冊(cè)帳號(hào)的手機(jī)號(hào),登錄時(shí)將自動(dòng)注冊(cè),且代表已同意
<a href="javascript:;" rel="external nofollow" rel="external nofollow" rel="external nofollow" >《用戶服務(wù)協(xié)議》</a>
</section>
</div>
<div :class="{on: !loginWay}">
<section>
<section class="login_message">
<input type="tel" maxlength="11" placeholder="手機(jī)/郵箱/用戶名">
</section>
<section class="login_verification">
<input type="tel" maxlength="8" placeholder="密碼">
<div class="switch_button off">
<div class="switch_circle"></div>
<span class="switch_text">...</span>
</div>
</section>
<section class="login_message">
<input type="text" maxlength="11" placeholder="驗(yàn)證碼">
<img class="get_verification" src="./images/captcha.svg" alt="captcha">
</section>
</section>
</div>
顯示效果如下所示:

總結(jié)
到此這篇關(guān)于vue 實(shí)現(xiàn)用戶登錄方式的切換功能的文章就介紹到這了,更多相關(guān)vue 登錄方式切換內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
- Vue實(shí)現(xiàn)用戶沒有登陸時(shí),訪問后自動(dòng)跳轉(zhuǎn)登錄頁面的實(shí)現(xiàn)思路
- Vue項(xiàng)目如何保持用戶登錄狀態(tài)(localStorage+vuex刷新頁面后狀態(tài)依然保持)
- vue實(shí)現(xiàn)用戶長時(shí)間不操作自動(dòng)退出登錄功能的實(shí)現(xiàn)代碼
- VuePress 中如何增加用戶登錄功能
- VUE:vuex 用戶登錄信息的數(shù)據(jù)寫入與獲取方式
- vue同一個(gè)瀏覽器登錄不同賬號(hào)數(shù)據(jù)覆蓋問題解決方案
- vue?+elementui?項(xiàng)目登錄通過不同賬號(hào)切換側(cè)邊欄菜單的顏色
- Vue實(shí)現(xiàn)登錄記住賬號(hào)密碼功能的思路與過程
- vue項(xiàng)目實(shí)現(xiàn)表單登錄頁保存賬號(hào)和密碼到cookie功能
- vue同一瀏覽器登錄多賬號(hào)處理方案
相關(guān)文章
詳解Vue全局組件的掛載之實(shí)現(xiàn)彈窗組件
這篇文章主要為大家詳細(xì)介紹了如何通過Vue全局組件的掛載來實(shí)現(xiàn)彈窗組件,文中的示例代碼講解詳細(xì),具有一定的借鑒價(jià)值,感興趣的可以了解一下2022-11-11
vue使用jsonp抓取qq音樂數(shù)據(jù)的方法
這篇文章主要介紹了vue使用jsonp抓取qq音樂數(shù)據(jù)的方法,非常不錯(cuò),具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2018-06-06
尤雨溪開發(fā)vue?dev?server理解vite原理
這篇文章主要為大家介紹了尤雨溪開發(fā)的玩具vite,vue-dev-server來理解vite原理,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2022-07-07
解決vue-cli3創(chuàng)建使用iview定制主題javascriptEnabled找不到該配置項(xiàng)
這篇文章主要介紹了解決vue-cli3創(chuàng)建使用iview定制主題javascriptEnabled找不到該配置項(xiàng)問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-04-04
Vue中對(duì)watch的理解(關(guān)鍵是immediate和deep屬性)
watch偵聽器,是Vue實(shí)例的一個(gè)屬性,是用來響應(yīng)數(shù)據(jù)的變化,需要在數(shù)據(jù)變化時(shí)執(zhí)行異步或開銷較大的操作時(shí),這個(gè)方式是最有用的,這篇文章主要介紹了Vue中對(duì)watch的理解,需要的朋友可以參考下2022-11-11

