store里的数据分成模块后,mapState辅助函数里应该怎么引模块的数据?
store文件结构:
- src
- components
- store
- index.js
- modules
- carts.js
store中index.js代码:
javascript">modules: {
carts,//注册carts模块
}
template代码:
<div style="margin-top:20px;">
{{price}}
</div>
辅助函数代码:
javascript">computed: {
...mapState({
price: state => state.carts.price;
})
}