vuex 存储订单类型的字段,如何让他在没有数据的时候再去请求接口?-灵析社区

爬虫爬呀爬

const orderMixin = { computed: { types() { return this.$store.state.types; } }, created() { this.$store.dispatch('updateTypes'); } } const store = new Vuex.Store({ state: { types: [] }, actions: { updateTypes (ctx) { if(!ctx.state.types.length) { // fetch } } } }) export default { name: 'A', mixins: [orderMixin], }

阅读量:1

点赞量:0

问AI