首先我们有三个页面
A页面:参数名称为:params:P006967
B页面:需要通过超链接,跳转到C页面 query/policydetaildom?policyNo=PA120A0000901
C页面:C页面有返回按钮,点击返回按钮将跳转到B页面
通过的技术为是state
1.创建一个js页面 /******/src/store/modules/client.js
const params = {
state:{
dealreturnparams:''
},
mutations: {
/**
* 添加公共信息
* @param state
* @param payload
*/
adddealreturnparams(state, payload) {
state.dealreturnparams = payload.clientCode;
}
}
}
const actions={
}
export default params
2.修改/******/src/store/index.js
import client from './modules/client'//新增的
Vue.use(Vuex)
const store = new Vuex.Store({
modules: {
app,
settings,
user,
product,
quotation,
permission,
client //新增的
},
getters
})
3.在B页面获取A页面的数据
created() {
//判断A页面传输过来的是否有数据,如果有数据B页面的参数直接获取
if(this.$route.params.clientCode!=undefined){
this.clientCode = this.$route.params.clientCode;
}else{
// A页面传输过来的没有有数据,通过state获取数据
this.clientCode =this.$store.state.client.dealreturnparams;
}
this.visitClientDetail(this.clientCode);
// 将信息存储到this.$store.state.client.dealreturnparams中
this.$store.commit({
type: "adddealreturnparams",
clientCode: this.clientCode
});
console.log( this.$store.state.client.dealreturnparams)
// this.$store.state.client.dealreturnparams=
},