Skip to content

Commit 34dfbcd

Browse files
committed
完成vuex流程
1 parent de0031b commit 34dfbcd

File tree

14 files changed

+399
-24
lines changed

14 files changed

+399
-24
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ indent_style = space
1212
insert_final_newline = true
1313
trim_trailing_whitespace = true
1414

15-
[*.{js,jsx,scss}]
15+
[*.{js,jsx,scss,vue}]
1616
indent_size = 2
1717

1818
# Tab indentation (no size specified)

client-vue/.babelrc

+2-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
"targets": {
55
"browsers": ["Android >= 4.0", "iOS >= 7"]
66
}
7-
}]
7+
}],
8+
"babel-preset-stage-0"
89
],
910
"ignore": [
1011
"node_modules"

client-vue/container/index/index.vue

+49-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,52 @@
11
<template>
2-
<div class="index-page">
3-
<div>index</div>
2+
<div class="index-page">
3+
<div class="user-info-wrap">
4+
<img class="avatar-img" :src="myInfo.avatar" :alt="myInfo.userName">
5+
<p class="user-name">{{myInfo.userName}}</p>
46
</div>
7+
</div>
58
</template>
9+
<script>
10+
import {mapGetters, mapActions, mapState} from 'vuex';
11+
12+
export default {
13+
data() {
14+
return {}
15+
},
16+
17+
computed: {
18+
...mapState({
19+
myInfo: state => {
20+
return state.main.myInfo
21+
}
22+
})
23+
},
24+
25+
methods: {
26+
...mapActions(['getMyInfo']),
27+
},
28+
29+
created() {
30+
this.getMyInfo();
31+
},
32+
33+
updated () {
34+
35+
}
36+
}
37+
</script>
38+
39+
<style lang="less">
40+
.user-info-wrap {
41+
text-align: center;
42+
margin-top: 30px;
43+
.avatar-img {
44+
width: 100px;
45+
height: 100px;
46+
border-radius: 50%;
47+
}
48+
.user-name {
49+
font-size: 20px;
50+
}
51+
}
52+
</style>

client-vue/package-lock.json

+211
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

client-vue/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"babel-loader": "^7.1.2",
2222
"babel-polyfill": "^6.26.0",
2323
"babel-preset-env": "^1.6.0",
24+
"babel-preset-stage-0": "^6.24.1",
2425
"cross-env": "^5.0.5",
2526
"css-loader": "^0.28.7",
2627
"extract-text-webpack-plugin": "^3.0.0",

client-vue/page/main/main.js

+9-17
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,10 @@ import Today from '../../container/today/today.vue';
99
import Rank from '../../container/rank/rank.vue';
1010
import Mine from '../../container/mine/mine.vue';
1111

12+
// vuex的store
13+
import store from '../../vuex';
14+
15+
// 路由配置
1216
Vue.use(VueRouter);
1317
let router = new VueRouter({
1418
routes: [
@@ -17,29 +21,17 @@ let router = new VueRouter({
1721
component: Frame,
1822
redirect: '/index',
1923
children: [
20-
{
21-
path: 'index',
22-
component: Index
23-
},
24-
{
25-
path: 'today',
26-
component: Today
27-
},
28-
{
29-
path: 'rank',
30-
component: Rank
31-
},
32-
{
33-
path: 'mine',
34-
component: Mine
35-
},
24+
{path: 'index', component: Index},
25+
{path: 'today', component: Today},
26+
{path: 'rank', component: Rank},
27+
{path: 'mine', component: Mine},
3628
]
3729
}
3830
]
3931
});
4032

4133
new Vue({
4234
el: '.doc',
43-
router,
35+
router, store,
4436
render: h => h(Wrap)
4537
});

0 commit comments

Comments
 (0)