|
@@ -1,5 +1,36 @@
|
|
|
<template>
|
|
|
<div class="about">
|
|
|
<h1>This is an about page</h1>
|
|
|
+ <h1> vuex中的状态值 {{ $store.state.count }}</h1>
|
|
|
+ <h1> vuex中的状态值 {{ count }}</h1>
|
|
|
+ <h1> vuex中的状态值 {{ str }}</h1>
|
|
|
+
|
|
|
+
|
|
|
+ <h1>当前页面引入的状态值 {{ vuexVal }}</h1>
|
|
|
+ <button @click="addCount(600)">修改状态值</button>
|
|
|
+ <!-- <button @click="changeVuex">修改状态值</button> -->
|
|
|
</div>
|
|
|
</template>
|
|
|
+<script>
|
|
|
+ import { mapMutations,mapState } from 'vuex';
|
|
|
+ export default{
|
|
|
+ name:"AboutView",
|
|
|
+ methods:{
|
|
|
+ ...mapMutations(["addCount"]),
|
|
|
+ // changeVuex(){
|
|
|
+ // // 调用 mutations 中的方法 this.$store.commit() 括号内第一个参数写入要调用的方法名称 从第二个参数开始时要传递的参数;
|
|
|
+ // this.$store.commit("addCount",300);
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ created(){
|
|
|
+ console.log(this.$store.state.count);
|
|
|
+ console.log(this.vuexVal);
|
|
|
+ },
|
|
|
+ computed:{
|
|
|
+ ...mapState(["count","str"]),
|
|
|
+ vuexVal(){
|
|
|
+ return this.$store.state.count
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+</script>
|