programing

템플릿에서 작업하지만 계산된 속성에서 작업하지 않는 혼합

prostudy 2022. 7. 27. 21:29
반응형

템플릿에서 작업하지만 계산된 속성에서 작업하지 않는 혼합

vue.js 컴포넌트에서는 다음과 같이 선언된 서플라이 스토어의 mixin을 사용하고 있습니다.

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개체를 반환합니다. 개체 길이는 항상 정의되지 않습니다!

언급URL : https://stackoverflow.com/questions/58454845/mixin-working-in-template-but-not-from-computed-property

반응형