第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定

出現(xiàn)一個問題,點擊“注冊”按鈕頁面進(jìn)入注冊表單后自動跳轉(zhuǎn)回登錄頁面

<template>
????<div>
????????<form?v-if="!isReg">
????????????用戶名:
????????????<input?type="text"?v-model="name">
????????????密碼:
????????????<input?type="text"?v-model="password">
????????????<button?type="button"?@click="login()">登錄</button>
????????????<button?type="button"?@click="reg()">注冊</button>
????????</form>
????????<form?v-else>
????????????用戶名:
????????????<input?type="text"?v-model="name">
????????????密碼:
????????????<input?type="text"?v-model="password">
????????????再次輸入密碼:
????????????<input?type="text">
????????????<button?@click="addUser()">確定</button>
????????????<button?@click="cancel()">取消</button>
????????</form>
????</div>
?</template>
?<script>
?export?default?{
?????name:?"Login",
?????data?()?{
?????????return?{
?????????????isReg:?false,
?????????????name:?'',
?????????????password:?'',
?????????????repeat:?''
?????????}
?????},
?????methods:?{
?????????login?()?{
?????????????this.$router.push('/home/list')
?????????},
?????????reg?()?{
?????????????this.isReg?=?true
?????????},
?????????cancel?()?{
?????????????this.isReg?=?false
?????????},
?????????addUser?()?{
?????????????localStorage.setItem("name",?this.name)
?????????????localStorage.setItem("password",?this.password)
?????????}
??????}
???}
</script>
<style>
</style>

請問老師如何解決bug?

正在回答

4 回答

1. form標(biāo)簽的action屬性會進(jìn)行跳轉(zhuǎn),所以form不給action標(biāo)簽,

2. 在button上的type不使用submit,因為submit會默認(rèn)執(zhí)行action屬性;

3. 在form標(biāo)簽、click上加入prevent修飾符,參考:修飾符事件修飾符


1 回復(fù) 有任何疑惑可以回復(fù)我~

第一個form表單中的button標(biāo)簽更換為div標(biāo)簽就不會有上訴問題了

1 回復(fù) 有任何疑惑可以回復(fù)我~

我也是這樣?但是不知道為啥。代碼和視頻里一模一樣的?自己會跳轉(zhuǎn)回去


0 回復(fù) 有任何疑惑可以回復(fù)我~

已找到問題所在,是因為form標(biāo)簽所導(dǎo)致的,換成div標(biāo)簽就沒有問題了,但是不知道為什么會產(chǎn)生這問題

1 回復(fù) 有任何疑惑可以回復(fù)我~

舉報

0/150
提交
取消

出現(xiàn)一個問題,點擊“注冊”按鈕頁面進(jìn)入注冊表單后自動跳轉(zhuǎn)回登錄頁面

我要回答 關(guān)注問題
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號