"getWatchLength"不是在实例上定义的,而是在渲染过程中引用的。确保在数据选项中声明反应式数据 vue js 属性



我有一个vuex store它存储了观看产品的长度状态,我得到了商店中产品的长度但每次我尝试在代码中{{getWatchlength}}时,我得到了"没有定义

这是我在控制台得到的错误https://imageshack.com/i/pmlnoX9nj

这是我的性用品店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>

拜托,我不知道我做错了什么

尝试如下:

import { mapGetters, mapActions } from 'vuex';
computed: {
...mapGetters(["getWatchLength", "isLoggedIn"])
}

相关内容

最新更新