站内搜索:
首页 >> 前端 >> 内容
vuex储存数据2.0的写法详解

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

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 							//获取

  • 上一篇:AJAX怎么实现将参数带到并传给另一个页面?
  • 下一篇:Set数据结构实例的属性和方法讲解
  • 返回顶部