VUE - mapState 辅助函数(简化)
1,第一种
<template>
<div id="app">
<p> {{count}} </p>
<p> {{todos}} </p>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'app',
computed:mapState({
count: state => state.count,
todos: state => state.todos
})
}
</script>
2,第二种,最简化
<template>
<div id="app">
<p> {{count}} </p>
<p> {{todos}} </p>
</div>
</template>
<script>
import {mapState} from 'vuex'
export default {
name: 'app',
computed:mapState(["count","todos"])
}
</script>
<style>
</style>