繁体   English   中英

插件 function 在 nuxt.js 中未定义

[英]plugin function undefined in nuxt.js

纪录片 nuxt.js 表明它有效。 链接但是,当我在我的组件生命周期挂钩“已安装”上调用我的插件 function 时,它显示“TypeError:无法读取未定义的属性 '$ProgramApi'”。 但是在常规方法中,插件在同一个组件中可以正常工作。 所以设置一定是对的

我对nuxt很陌生。

<script>
export default {
  data()  {
    return {
      programs: []
    }
  },
  mounted: () => {
    console.log(this.$ProgramApi.agenda());
  },
  methods: {
    test() {
      this.$ProgramApi.conferenceRooms().then(res => {
        console.log(res);
      });
    }
  }
}
</script>

mounted的 function 更改为常规 function。 不要使用 ES-6 语法。

代替:

mounted: () => {
  console.log(this.$ProgramApi.agenda()); // this will refer to mounted instance
},

利用:

mounted() {
  console.log(this.$ProgramApi.agenda()); // this will refer to vue instance
},

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM