一、mapState方法获取vuex中的数据
当store中的数据比较多的时候,可以用这个函数去获取数据
export default new Vuex.Store({state:{city:"武汉",name:"程超",sex:"男",age:20}})
<template><div class="home"><h1>首页</h1><h2>{{city}}</h2></div></template><script>import {mapState} from 'vuex';export default {computed:{...mapState(['city','name','age','sex'])}}</script>
