-1👍
You can try using the validator
function available for props.
validator
: Function Custom validator function that takes the prop value as the sole argument. In a non-production environment, a console warning will be thrown if this function returns a falsy value (i.e. the validation fails).
alternatively, you could add custom validation either through a lifecycle hook like mounted
or using a watch
. The lifecycle method is OK if you know the prop values are not changing, if they are not static, then use a watch
which is a more reliable solution.
- [Vuejs]-Best place for function which checks permissions in vue.js
- [Vuejs]-VueTwo Way Data Binding with Nested Components
Source:stackexchange.com