天天看點

vuex詳細分析

<template>
  <div class="hello">
    <h1>{{ msg }}</h1>
    {{b}}{{q}}{{aa}}
    <button @click="getValue(1)">點選</button>
    <button @click="setAA">點選</button>
  </div>
</template>

<script>
import {mapGetters,mapActions,mapState,mapMutations} from 'vuex'
export default {
  name: 'HelloWorld',
  data () {
    return {
      msg: 'Welcome to Your Vue.js App'
    }
  },
  computed:{
    ...mapState(['q','aa']),
    ...mapGetters(['b'])
  },
  methods:{
    ...mapActions(['getValue']),
    ...mapMutations(['setAA'])
  },
  mounted () {
    console.log(this.b)
  }
}
</script>      

繼續閱讀