微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

registerModule + serverPrefetch + unregisterModule

如何解决registerModule + serverPrefetch + unregisterModule

Git https://github.com/Mitch-i/vue-ssr

从一页导航到另一页。

  serverPrefetch () {
        // return the Promise from the action
        // so that the component waits before rendering
        this.$store.registerModule('Locale',Locale);
        return this.getUsers();
    },// Client-side only
    // beforeMount() {
    //     this.$store.registerModule('Locale',Locale,{ preserveState: true });
    // },mounted () {alert('bm home');
        this.$store.registerModule('Locale',{ preserveState: true });
        // If we didn't already do it on the server,we fetch the users
        if (!this.users.length) {
            this.getUsers();
        }
    },methods: {
        getUsers () {
            return this.$store.dispatch('getUsers');
        }
    },destroyed() {alert('destroyed home');
      this.$store.unregisterModule('Locale');
    },

无法读取未定义的属性“ locale” 我尝试使用不同的钩子并得到不同的错误。最后,它肯定无法正常工作。

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。