如何访问 v-for 循环中的 data() 值?

问题描述 投票:0回答:0
div v-for="item in this.itemList"
  div v-if="this.author"
  div v-if="this.testBoolean"




name: "test",
auth: false,
data() {
return {
author: this.$auth.user.uid,
testBoolean: true,



TypeError: Cannot read properties of undefined (reading 'author')


So while using a v-for loop, I want to access values in the data(). Does anyone know how to access them? It would seem the template is being made before the data is being made so it cannot access "this".

我已经尝试访问 for 循环之外的值并且它工作正常。

我想主要的问题是你不能在 v-for 中访问它?

我不知道还要在这里输入什么,因为在我输入更多之前它不会让我发帖,但我已经放下了我所知道的一切

vue.js nuxt.js v-for
© www.soinside.com 2019 - 2024. All rights reserved.