mirror of
https://github.com/sunniejs/vue-h5-template.git
synced 2025-04-05 07:03:01 +08:00
21 lines
438 B
TypeScript
21 lines
438 B
TypeScript
/**
|
|
* 类型检查
|
|
*/
|
|
|
|
export function typeCheck(param: any) {
|
|
return Object.prototype.toString.call(param);
|
|
}
|
|
|
|
/**
|
|
* 批量修改stage
|
|
*/
|
|
export function mutateState(state: AnyObject, payload: AnyObject) {
|
|
if (typeCheck(state) === '[object Object]' && typeCheck(payload) === '[object Object]') {
|
|
for (const key in payload) {
|
|
state[key] = payload[key];
|
|
}
|
|
} else {
|
|
console.error('expected plain Object');
|
|
}
|
|
}
|