我正在使用nuxt.js,我得到了这个错误
语法错误:意外保留字“等待”
这是密码
<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>发布于 2021-06-20 14:47:06
您正在导出一个对象。对象具有键值对。
您尚未为异步fetch()和data定义键
考虑这样做。
export default {
middleware: 'auth',
fetch: async () => {
await this.$auth
.fetchUser()
.then((response) => (this.loggedInUser = response.data.data))
},
data: () => {
return {
loggedInUser: this.$auth.user.data,
}
},
}https://stackoverflow.com/questions/68056946
复制相似问题