iview組件之select綁定類型number

本文僅記錄在select使用過程中出現的不常見問題,一般的使用問題,請直接在官網查看。
1,有時後端使用的數據是int類型,也就是說,你要綁定的value是數字,使用官網上的驗證方法是無法通過檢測的,這個時候怎麼辦呢?官網上使用的驗證規則是 async-validator,該規則中rule的type是這樣定義的string: Must be of type string. This is the default type.,因此,按照官網上的寫法{ required: true, message: 'Please select the city', trigger: 'change' },實際上完整的驗證應該是{ required: true, message: 'Please select the city', trigger: 'change',type:'string' },因此當我們選中value是數字1的時候,因爲類型不對,故而檢測不通過。說到這裏,你應該已經知道了怎麼修改了,{ required: true, message: 'Please select the city', trigger: 'change',type:'number' }

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章