gpt4 book ai didi

vuejs2 - Mixin 在模板中工作但不是来自计算属性

转载 作者:行者123 更新时间:2023-12-05 07:18:13 24 4
gpt4 key购买 nike

在 vue.js 组件中,我使用了来自 supply store 的 mixins,声明如下:

mixins: [
use('Categories'),
],

computed: {
...mapGetters({
getMainCategories: 'categories/getMainCategories',
ss: 'categories/getSubcategories',
}),
(...)

当我直接在模板 {{getMainCategories}} 中访问它时它工作正常,但是当我尝试从另一个计算属性访问它时:

 categoriesSelectValues() {
if (this.getMainCategories.length > 0) {

}
else return []
}

我明白了

[Vue warn]: Error in render: "TypeError: this.getMainCategories is undefined"

我完全不知道出了什么问题,尤其是我有另一个 - 几乎相同的组件 - 工作正常。

最佳答案

this.getMainCategories 返回一个对象 - 长度始终未定义!

关于vuejs2 - Mixin 在模板中工作但不是来自计算属性,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58454845/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com