使用iview的input組件,無法使用watch<Input type="text" v-model.trim="account" size="large" placeholder="請(qǐng)輸入手機(jī)號(hào)" :maxlength="11"></Input>watch: { account: function() { this.account = this.account.replace(/[^\d]/g,''); }},不起作用,但是我換成普通的input就沒問題<input type="text" v-model.trim="account">文檔上也沒其他說明,是我用法不對(duì)嗎?我打印了下值,發(fā)現(xiàn)是起作用的watch: { account: function() { //console.log(this.account); this.account = this.account.replace(/[^\d]/g,''); console.log(this.account); } },此時(shí),this.account的值輸入非數(shù)字已經(jīng)被替換掉了,但是輸入框的值沒有被更新,等于數(shù)據(jù)變成單向的了,不明白是怎么回事。初步判斷問題的原因可能是 父子組件間的數(shù)據(jù)只能是單向的緣故。
iview input組件無法使用watch?
尚方寶劍之說
2018-12-12 14:15:03