首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >语法错误:意外的保留词“等待”

语法错误:意外的保留词“等待”
EN

Stack Overflow用户
提问于 2021-06-20 14:42:06
回答 1查看 2K关注 0票数 1

我正在使用nuxt.js,我得到了这个错误

语法错误:意外保留字“等待”

这是密码

代码语言:javascript
复制
<template>
  <div class="mt-6">loggedInUser: {{ loggedInUser }}</div>
</template>

<script>
export default {
  middleware: 'auth',
  async fetch() {
    await this.$auth
      .fetchUser()
      .then((response) => (this.loggedInUser = response.data.data))
  },
  data() {
    return {
      loggedInUser: this.$auth.user.data,
    }
  },

}
</script>

<style>

</style>
EN

回答 1

Stack Overflow用户

发布于 2021-06-20 14:47:06

您正在导出一个对象。对象具有键值对。

您尚未为异步fetch()data定义键

考虑这样做。

代码语言:javascript
复制
export default {
  middleware: 'auth',
  fetch: async () => {
    await this.$auth
      .fetchUser()
      .then((response) => (this.loggedInUser = response.data.data))
  },
  data: () => {
    return {
      loggedInUser: this.$auth.user.data,
    }
  },

}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/68056946

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档