码迷,mamicode.com
首页 > 其他好文 > 详细

state访问状态对象

时间:2017-08-30 18:32:42      阅读:167      评论:0      收藏:0      [点我收藏+]

标签:map   img   images   通过   from   turn   分享   bsp   技术分享   

状态对象赋值给内部对象,也就是把stroe.js中的值,赋值给我们模板里data中的值。我们有三种赋值方式:

1.通过computed的计算属性直接赋值

Count.vue

{count}

<script>

export default {

computed:{
 count () {
 return this.$store.state.count;
 }
 },
store
}

</script>

2.通过mapState的对象来赋值

Count.vue

技术分享

3.通过mapState的数组来赋值

Count.vue

import {mapState} from ‘vuex‘;

技术分享

 

state访问状态对象

标签:map   img   images   通过   from   turn   分享   bsp   技术分享   

原文地址:http://www.cnblogs.com/zhouyx/p/7454324.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!