Home

Issue: 2297

root methods is not a function when i refresh page

[issue link]

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 myMethodisok,igetaconsolelogbutirefreshthispageiwillgetthiserroronmypage,this.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);
  }
This question is available on Nuxt.js community (#c2011)