How does the vue instruction directive accept multiple parameters?

suppose I have an input, that can only enter numbers, and the length and the number of decimal places are limited, so I need two parameters. How can I pass it and get it in the instruction?

here is the code that I pass a parameter or get, as follows:

<input type="text" v-spec-input="8">
directives: {
    spec_input: {
        bind: function (el, binding) {
            //
            console.log(binding.value)
        }
    },
}        
Mar.07,2021
The form of

object is passed in


<input type="text" numberLength='8' pointLength='3'>
directives: {
    spec_input: {
        bind: function (el, binding) {
            //
            console.log(el.attributes.numberLength.value,el.attributes.pointLength.value )
        }
    },
}      

this should work.


parameters are passed as objects or arrays


Thank you, everyone. I found

<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!"
})
Menu