dt-charts
Version:
基于echarts封装的vue组件,配置项与数据分离,简少代码量
14 lines (13 loc) • 345 B
JavaScript
export function set (target, path, value) {
if (!path) return
let targetTemp = target
const pathArr = path.split('.')
pathArr.forEach((item, index) => {
if (index === pathArr.length - 1) {
targetTemp[item] = value
} else {
if (!targetTemp[item]) targetTemp[item] = {}
targetTemp = targetTemp[item]
}
})
}