VueAuthenticate - Uncaught TypeError: Cannot read property 'login' of undefined

VueAuthenticate - Uncaught TypeError: Cannot read property 'login' of undefined

我为 VueJS 2 使用 Vue 身份验证 (https://github.com/dgrubelic/vue-authenticate)。

当我点击登录按钮时出现错误,我在 this.$auth 中找不到 login :/

错误:

Uncaught TypeError: Cannot read property 'login' of undefined at VueComponent.login (Login.vue?9314:70) at Proxy.boundFn (vue.esm.js?efeb:187) at click (Login.vue?8b9b:195) at invoker (vue.esm.js?efeb:1937) at HTMLButtonElement.fn._withTask.fn._withTask (vue.esm.js?efeb:1772)

代码:

<v-btn color="orange darken-1" flat @click.native="login()">Login</v-btn>

JS文件store.js:

methods: {
    login () {
      this.$auth.login(this.user).then(() => {
        alert('ok')
      }).catch(() => {
        alert('error')
      })
    }
  }

VueJS 实例:

new Vue({
  el: '#app',
  store,
  router,
  template: '<App/>',
  components: { App }
})

错误消息告诉您 $auth 未定义。您是否像文档中解释的那样使用 Vue.use 注册了插件?如果不注册插件,它将无法在 Vue 实例上使用。