&quot“ getWatchLength”不是在实例上定义的,而是在渲染过程中引用的。确保在数据选项中声明反应性数据VUE JS属性

发布于 2025-02-08 03:00:24 字数 971 浏览 1 评论 0原文

我有一个Vuex商店,它存储了监视产品长度的状态,我会在商店中获得产品长度,但是每次尝试在代码中尝试{{getWatchLength}}时,我都会获得“ getWatchLength

”我进入控制台 https://imageshack.com/i/pmlnox9nj

这是我的VUEX商店 https://imageshack.com/i/pmp87o5ij

html代码

<template>
  <div id="app">
    {{ getWatchLength }}
    <router-view></router-view>
  </div>
</template>

我的脚本标签

<script>
import { mapActions } from "vuex";
import { mapGetters } from "vuex";
export default {
  name: "app",
  data() {
    return {
      categoryID: null,
      categories: [],
      products: [],
      show: null
    };
  },
  computed: {
    ...mapGetters( ["getWatchLength"], ["isLoggedIn"])
  }
};
</script>

,我不知道我在做什么错

I've a vuex store which stores the state of the length of watched products, I get the length of product in my store but each time I try to {{getWatchlength}} in my code i get "getWatchlength" not defined

This the error I get in my console https://imageshack.com/i/pmlnoX9nj

This my vuex store
https://imageshack.com/i/pmP87O5Ij I'm getting the length in my store

This my html code

<template>
  <div id="app">
    {{ getWatchLength }}
    <router-view></router-view>
  </div>
</template>

My script tag

<script>
import { mapActions } from "vuex";
import { mapGetters } from "vuex";
export default {
  name: "app",
  data() {
    return {
      categoryID: null,
      categories: [],
      products: [],
      show: null
    };
  },
  computed: {
    ...mapGetters( ["getWatchLength"], ["isLoggedIn"])
  }
};
</script>

Please, I don't know what I'm doing wrong

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

悲凉≈ 2025-02-15 03:00:24

尝试以下类似:

import { mapGetters, mapActions } from 'vuex';

computed: {
  ...mapGetters(["getWatchLength", "isLoggedIn"])
}

Try like following:

import { mapGetters, mapActions } from 'vuex';

computed: {
  ...mapGetters(["getWatchLength", "isLoggedIn"])
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文