registerModule: 动态注册vuex模块,对于自定义生成组件很有用
registerModule: 动态注册vuex模块
<div class="reference">在 store 创建之后,你可以使用 store.registerModule 方法注册模块:registerModule</div>动态注册vuex模块,对于自定义生成组件很有用
<!--more-->
实现方案
- html
<div> {{message}} <div style="color: red; font-size: 20px">注册前后store中modules对比:</div> <div v-for="(item, key, index) in $store.state">{{key}} {{item}}</div> <Button type="primary" size="small" @click="registerModule">registerModule</Button> </div>
- js
registerModule () { this.$store.registerModule('registerModule', { state: {}, mutations: {}, actions: {}, getters: {} }) }
结尾
相关推荐
CSCCockroach 2020-09-15
lbPro0 2020-07-05
MrSunOcean 2020-06-21
lylwanan 2020-06-14
Callmesmallpure 2020-05-31
ShaLiWa 2020-05-25
墨龙吟 2020-04-24
MrSunOcean 2020-04-24
H女王范儿 2020-04-22
lbPro0 2020-04-16
ShaLiWa 2020-02-29
ShaLiWa 2020-01-17
MrSunOcean 2020-01-03
lbPro0 2020-01-01
H女王范儿 2019-12-29