I'm building a custom Vue JS plugin using the vue create
CLI. I've imported my various packages, however, I'm getting an error when trying to use custom settings with VeeValidate.
plugin.js
/*
* NOTE:
* This file is plugin stub for main.js
*/
// Import required packages
import Vue from 'vue'
import VeeValidate from 'vee-validate'
import VueResource from 'vue-resource'
import BootstrapVue from 'bootstrap-vue'
// Import custom LES form styling
import './assets/scss/les-application.scss'
// Import our plugin
import plugin from './index'
/* Vue Validation */
const config = {
fieldsBagName: 'fields',
errorBagName: 'errors',
classes: true,
strict: false,
classNames: {
valid: '',
invalid: 'is-invalid'
},
events: 'change|blur',
validity: false,
inject: false,
aria: true,
delay: 0
}
Vue.use(require('vue-moment'))
Vue.use(VueResource)
Vue.use(VeeValidate, config)
Vue.use(plugin)
// Custom validation rules
/*
* NOTE:
* If you want Vue instance of main.js to import something in your plugin as a Vue option,
* you need to export it here.
*/
// export default plugin
main.js
import Vue from 'vue'
import App from './App.vue'
import './plugin'
Vue.config.productionTip = false
new Vue({
render: h => h(App),
}).$mount('#app')
Errors:
Property or method "errors" is not defined on the instance but referenced during render. Make sure that this property is reactive, either in the data option, or for class-based components, by initializing the property.
and
Cannot read property 'has' of undefined
I'm trying to figure out what I'm missing from my configuration, if I remove the VeeValidate config from plugin.js
it then uses the default VeeValidate options and is working.
/src/components/MyComponent.vue
– Ryan HMyComponent.vue
then? – Ryley