假设我有一个只能输入数字的input,并且长度和小数点后位数有限制,那么我就需要两个参数了,我该如何传递和指令里面获取呢?下面是我传递一个参数或获取的代码,如下:<input type="text" v-spec-input='8'>directives: { spec_input: {
bind: function (el, binding) {
//获取
console.log(binding.value)
}
},
}
2 回答

MYYA
TA贡献1868条经验 获得超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贡献1809条经验 获得超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 ) } }, }
这样应该可以。
- 2 回答
- 0 关注
- 1558 浏览
添加回答
举报
0/150
提交
取消