您现在的位置:首页 >> 前端 >> 内容

vuex储存数据2.0的写法详解

时间:2018/5/10 15:08:04 点击:

  核心提示:vuex储存数据2.0的写法详解import Vuex from vuex //最上面要写上这一行 methods:{ setData: function(){ this.$store.dis...

vuex储存数据2.0的写法详解

        import Vuex from 'vuex'		//最上面要写上这一行
	methods:{
		setData: function(){
			this.$store.dispatch('SET_NAME', this.name);			//在一个方法里面,这就能将this.name存起来
			this.$store.dispatch('SET_OLDPRICE', this.oldPrice);
		},
	},
	computed: Vuex.mapGetters({
        name: 'getName',
        oldPrice: 'getOldPrice',
	}),


	this.name = this.$store.state.getName 							//获取

Tags:VU UE EX X储 
作者:网络 来源:ljw_jiawei