uniapp记录一下数据存入缓冲然后取出

创建了一个新的js文件,引入Vue和Vuex库,通过Vue.use(Vuex)启用Vuex插件。定义了一个VuexStore,包含state和mutations,用于存储和修改oldMainId的状态。在页面中,通过this.$store.commit(setOldMainId,value)保存数据到缓冲区,然后在需要的地方通过this.$store.state.oldMainId读取该值。
摘要由CSDN通过智能技术生成

1.新建一个文件夹,新建js文件

js文件内容

// 页面路径:store/index.js 
import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex); //vue的插件机制

//Vuex.Store 构造器选项
const store = new Vuex.Store({
	state: { //存放状态
		oldMainId:"",	
		
	},
	mutations: {
		setOldMainId(state, oldMainId) {
			state.oldMainId = oldMainId
         },
	}

})
export default store

2.页面调用

this.$store.commit('setOldMainId', this.careCenterItem.deptId)

将你需要的值存入的缓冲中

3.在你需要调用的地方使用

this.oldMainId = this.$store.state.oldMainId;

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值