假設(shè)我有一個只能輸入數(shù)字的input,并且長度和小數(shù)點后位數(shù)有限制,那么我就需要兩個參數(shù)了,我該如何傳遞和指令里面獲取呢?下面是我傳遞一個參數(shù)或獲取的代碼,如下:<input type="text" v-spec-input='8'>directives: { spec_input: {
bind: function (el, binding) {
//獲取
console.log(binding.value)
}
},
}
2 回答

MYYA
TA貢獻(xiàn)1868條經(jīng)驗 獲得超4個贊
<div v-demo="{ color: 'white', text: 'hello!' }"></div>
Vue.directive('demo', function (el, binding) {
console.log(binding.value.color) // => "white"
console.log(binding.value.text) // => "hello!"
})

海綿寶寶撒
TA貢獻(xiàn)1809條經(jīng)驗 獲得超8個贊
<input type="text" numberLength='8' pointLength='3'>
directives: { spec_input: { bind: function (el, binding) { //獲取 console.log(el.attributes.numberLength.value,el.attributes.pointLength.value ) } }, }
這樣應(yīng)該可以。
- 2 回答
- 0 關(guān)注
- 1583 瀏覽
添加回答
舉報
0/150
提交
取消