這個問題困擾了我一個多小時,各種測bug !始終測不出來!
直接上代碼(錯誤示范)
<el-form-item prop="password">
<el-input
@keyup.enter="check('form')" //在vue中這個代碼是可行的
type="password"
v-model="form.password"
placeholder="密碼"
prefix-icon="myicon myicon-key"
></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" class="login-button" @click="check('form')">登錄</el-button>
</el-form-item>
但是問題是:如果我們使用第三方組件這個方法並不奏效了 這時我們應該這么寫 )
注意:這是我們必須在@keyup.enter后面加一個native 來確保這個功能能夠得到實現
<el-form-item prop="password">
<el-input
@keyup.enter.native="check('form')"
type="password"
v-model="form.password"
placeholder="密碼"
prefix-icon="myicon myicon-key"
></el-input>
</el-form-item>
<el-form-item>
<el-button type="primary" class="login-button" @click="check('form')">登錄</el-button>
</el-form-item>
