将参数存到store并从中拿出来的方法
页面中要将数据存到vuex 中的方法
this.$store.commit("print/setPrint", {
ID: this.ID,
BrandID: 46
});
【将参数存到store并从中拿出来的方法】Store的写法
// initial state
const state = {
all: {
ID:'',
BrandID:''
}
}// getters
const getters = {}// actions
const actions = {
// getAllPurchasedTools ({ commit }) {
//purchasedTools.getPurchasedTools((tools) => {
//commit('setPurchasedTools',tools)
//},state.params);
// }
}// mutations
const mutations = {
setPrint(state, all) { //设置参数
state.all = all;
}
}export default {
namespaced: true,
state,
getters,
actions,
mutations
}
然后在store下面的index.js文件中
import print from './module/print';
export default new Vuex.Store({
modules: {
print
},
strict: debug,//开启严格模式
plugins: debug ? [createLogger()] : []
})
用到的页面
import { mapState, mapActions } from "vuex";
computed: {
...mapState({
print:state=>state.print.all
})
}
在用到的地方直接this点出来即可
this.CreateUserID = this.print.ID;
this.GoodsID = this.print.BrandID;
推荐阅读
- JAVA(抽象类与接口的区别&重载与重写&内存泄漏)
- 即将到手三百万
- 思友人
- 不废话,代码实践带你掌握|不废话,代码实践带你掌握 强缓存、协商缓存!
- 20210307《挑战赛怂人胆》【能量将帅挑战赛(01)】
- 苍灵十二将I|苍灵十二将I 第一百二十五章 关门猎兽
- 那条灰色的人行道
- 《没有你我将会很幸福》
- 【挑战日更】Day6.《终身学习.10个你必须掌握的未来生存法则》摘录之三
- 在这个时代每个女性都应该用个性的服装来证明自己的存在