v
This commit is contained in:
commit
552d0dfbf0
@ -1,41 +1,20 @@
|
||||
// 商品相关
|
||||
const moduleA = {
|
||||
state: () => ({
|
||||
count: 0
|
||||
}),
|
||||
mutations: {
|
||||
increment (state) {
|
||||
// 这里的 `state` 对象是模块的局部状态
|
||||
state.count++
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
doubleCount (state) {
|
||||
return state.count * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
// 用户相关
|
||||
const moduleB = {
|
||||
state: () => ({
|
||||
count: 0
|
||||
}),
|
||||
mutations: {
|
||||
increment (state) {
|
||||
// 这里的 `state` 对象是模块的局部状态
|
||||
state.count++
|
||||
}
|
||||
},
|
||||
getters: {
|
||||
doubleCount (state) {
|
||||
return state.count * 2
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
import Vue from 'vue'
|
||||
import Vuex from 'vuex'
|
||||
Vue.use(Vuex)
|
||||
|
||||
const store = new Vuex.Store({
|
||||
modules: {
|
||||
shop: moduleA,
|
||||
user: moduleB
|
||||
state: {
|
||||
count: 0
|
||||
},
|
||||
getters: {
|
||||
doubleCount (state) {
|
||||
return state.count * 2
|
||||
}
|
||||
},
|
||||
mutations: {
|
||||
increment (state) {
|
||||
state.count++
|
||||
}
|
||||
}
|
||||
})
|
||||
})
|
||||
export default store;
|
11
main.js
11
main.js
@ -1,19 +1,18 @@
|
||||
import Vue from 'vue'
|
||||
import App from './App'
|
||||
import uView from "uview-ui"
|
||||
import Vuex from 'vuex'
|
||||
|
||||
// import Vuex from 'vuex'
|
||||
import uView from "uview-ui";
|
||||
Vue.config.productionTip = false
|
||||
Vue.use(uView);
|
||||
Vue.use(Vuex);
|
||||
App.mpType = 'app'
|
||||
|
||||
// import store from '@/common/store/index.js'
|
||||
import store from '@/common/store/index.js'
|
||||
|
||||
Vue.prototype.$store = store;
|
||||
|
||||
const app = new Vue({
|
||||
...App,
|
||||
// store
|
||||
store
|
||||
})
|
||||
// http拦截器,将此部分放在new Vue()和app.$mount()之间,才能App.vue中正常使用
|
||||
import httpInterceptor from '@/common/http.interceptor.js'
|
||||
|
@ -41,8 +41,8 @@
|
||||
<view class="hr" style="margin-top:40rpx"></view>
|
||||
<seckill v-if="spikeList.length"></seckill>
|
||||
<view v-if="spikeList.length" class="hr" style="margin-top:40rpx"></view>
|
||||
<!-- <recommend></recommend> -->
|
||||
<!-- <view class="hr" style="margin-top:40rpx"></view> -->
|
||||
<recommend v-if="0"></recommend>
|
||||
<view class="hr" style="margin-top:40rpx" v-if="0"></view>
|
||||
<group></group>
|
||||
<image class="lingquan"></image>
|
||||
<youhq></youhq>
|
||||
@ -95,7 +95,6 @@ export default {
|
||||
this.getGoodsRecommend();
|
||||
},
|
||||
onShow() {
|
||||
// console.log(this.$store.shop.state.count);
|
||||
this.getRecommendedSpike();
|
||||
this.getSpikeList();
|
||||
},
|
||||
|
Loading…
Reference in New Issue
Block a user