You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

19 lines
484 B
JavaScript

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

// 暂时不用vuex模块方式实现将该方法直接放入到/store/index.js中
const module = {
actions: {
$uStore({rootState}, params) {
let nameArr = params.name.split('.');
if(nameArr.length >= 2) {
let obj = rootState[nameArr[0]];
for(let i = 1; i < nameArr.length - 1; i ++) {
obj = obj[nameArr[i]];
}
obj[nameArr[nameArr.length - 1]] = params.value;
} else {
rootState[params.name] = params.value;
}
}
}
}
export default module