master
ewall 6 years ago
parent 5f893153d4
commit db91cd1264

@ -38,6 +38,7 @@
- chapter33 vuex初探(一)
- chapter34 vuex初探(二)
- chapter35 vuex初探(三)
- chapter36 vuex初探(四)
- MongoDB的安装
- MongoDB服务的配置
- MongoDB基本语法

@ -1,11 +1,14 @@
<template>
<div class="test">
<router-link to="/testCity">返回testCity页面</router-link>
<div>获取vuex中的值{{this.$store.state.city}}</div>
<!-- <div>获取vuex中的值{{this.$store.state.city}}</div> -->
<div>获取vuex中的值{{this.city}}</div>
</div>
</template>
<script>
import { mapState } from "vuex";
export default {
name: "test",
components: {},
@ -17,7 +20,11 @@ export default {
created() {},
mounted() {},
watch: {},
computed: {},
computed: {
// 使mapState
// this.citythis.$store.state.city
...mapState(["city"])
},
methods: {}
};
</script>

@ -14,6 +14,8 @@
</template>
<script>
import { mapActions } from "vuex";
export default {
name: "TestCity",
components: {},
@ -28,8 +30,12 @@ export default {
computed: {},
methods: {
click(city) {
this.$store.dispatch("changeCity", city);
}
// this.$store.dispatch("changeCity", city);
// mapActionsthis.changeCity()this.$store.dispatch('changeCity')
this.changeCity(city);
},
...mapActions(["changeCity"])
}
};
</script>

Loading…
Cancel
Save