Ao dar um console.log(this), Eu queria que o THIS do console retornasse o Vue, e não o This do Validate,
this.$ValidateUtil({ el: this.$refs.cadMain, rules: { cep: { required: true, regex: /^\d{5}-\d{3}$/ } }, messages: { cep: { regex: "CEP inválido" } }, submitHandler: function () { // AQUI!! -->>console.log(this); return false; } })
import Vue from 'vue'
import 'jquery-validation'
var LibsUtil = (function () {
function LibsUtil() {
}
LibsUtil.ValidateUtil = function (options) {
options = options || {}
$(options.el).validate({
rules: options.rules || {},
messages: options.messages || {},
submitHandler: function (form) {
if (typeof options.submitHandler !== 'undefined') {
options.submitHandler(this, form)
}
return false;
}
})
Return Vue;
};
LibsUtil.install = function (Vue) {
Vue.ValidateUtil = LibsUtil.ValidateUtil;
if (!Vue.prototype.hasOwnProperty("$ValidateUtil")) {
Vue.prototype.$ValidateUtil = LibsUtil.ValidateUtil;
}
};
return LibsUtil;
}());
export { LibsUtil };
export default LibsUtil;