小编mad*_*mad的帖子

Vuex Mutation正在运行,但组件不会更新,直到在vue dev工具中手动提交

我有一个Vue组件,无法从服务调用中填充的计算属性中进行更新。

Feed.vue

<template>
    <div class="animated fadeIn">
        <h1 v-if="!loading">Stats for {{ feed.name}}</h1>      
        <h2 v-if="loading">loading {{ feedID }}</h2> 
    </div>
</template>
<script>
    export default {
        data: () => {
            return {
                feedID: false
            }
        },
        computed: {
            feed(){
                return this.$store.state.feed.currentFeed
            },
            loading(){
                return this.$store.state.feed.status.loading;
            }
        },
        created: function(){    
            this.feedID = this.$route.params.id;
            var fid = this.$route.params.id;
            const { dispatch } = this.$store;
            dispatch('feed/getFeed', {fid});
        }
    }
</script>
Run Code Online (Sandbox Code Playgroud)

从feed模块分派'feed / getFeed'...

feed.module.js

import { feedStatsService } from '../_services';
import { router } from '../_helpers';

export …
Run Code Online (Sandbox Code Playgroud)

javascript vue.js vuex

6
推荐指数
1
解决办法
2302
查看次数

标签 统计

javascript ×1

vue.js ×1

vuex ×1