You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
26 lines
550 B
26 lines
550 B
class WxData { |
|
constructor(component) { |
|
this.Component = component |
|
} |
|
getData(key) { |
|
const data = this.Component.data |
|
if (!key) return data |
|
if (key.includes('.')) { |
|
let keys = key.split('.') |
|
const tmp = keys.reduce((prev, next) => { |
|
return prev[next] |
|
}, data) |
|
return tmp |
|
} else { |
|
return this.Component.data[key] |
|
} |
|
} |
|
setData(data, cb = () => {}) { |
|
if (!data) return |
|
if (typeof data === 'object') { |
|
this.Component.setData(data, cb) |
|
} |
|
} |
|
} |
|
|
|
export default WxData
|
|
|