Currently, I am engaged in a project using nuxt.js where I am implementing a function into the application context as advised by the official documentation.
https://nuxtjs.org/guide/plugins/#inject-in-root-amp-context
However, I encountered an issue when trying to invoke the function within a props validation process.
/plugins/check-props.js
import Vue from 'vue'
Vue.prototype.$checkProps = function(value, arr) {
return arr.indexOf(value) !== -1
}
This is happening within a Vue component:
export default {
props: {
color: {
type: String,
validator: function (value, context) {
this.$checkProps(value, ['success', 'danger'])
}
}
}
ERROR:
Cannot read property '$checkProps' of undefined
I am seeking guidance on how to access "this" within the validation process.
Your help will be much appreciated. Thank you!