I am creating a validation component to be published. Just like vee-validate I want to use a variable this.$validate.bla() ? where bla is function in my component.
CodePudding user response:
in your main file:
import Validate from 'your_validation_module';
Object.defineProperty(Vue.prototype, '$Validate', {
value: Validate
});
then use like this in your code :
this.$Validate.blah()
in Vue3 you should use Provide/Inject , app level provide