I code a plugins as vue doc
import Vue from 'vue'
let MyPlugin = {}
MyPlugin.install = function (Vue, options) {
Vue.prototype.$myMethod = function (methodOptions) {
console.log(window)
}
}
Vue.use(MyPlugin)
this is my nuxt config
{
src: '~plugins/utils',
ssr: false
},
'~plugins/element-ui'
]
when i use $myMethod
module.exports = {
data () {
return {
text: 'lee'
}
},
created () {
console.log(this.$myMethod())
}
}
</script>
if i don' t refresh this page the $myMethod is ok , i get a console log
but i refresh this page i will get this error on my page ,
this.$myMethod is not a function
i console.log(this.$myMethod) i get this but i can't use this function because this is not a function . hahahah~
ƒ (methodOptions) {
console.log(window);
}
<!--cmty--><!--cmty_prevent_hook--><div align="right"><sub><em>This question is available on <a href="https://nuxtjs.cmty.io">Nuxt.js</a> community (<a href="https://nuxtjs.cmty.io/nuxt/nuxt.js/issues/c2011">#c2011</a>)</em></sub></div>