mirror of
https://gitee.com/vant-contrib/vant-weapp.git
synced 2025-04-06 03:58:05 +08:00
32 lines
553 B
JavaScript
32 lines
553 B
JavaScript
export function observeProps(props) {
|
|
if (!props) {
|
|
return;
|
|
}
|
|
|
|
Object.keys(props).forEach(function (key) {
|
|
var prop = props[key];
|
|
|
|
if (prop === null || !('type' in prop)) {
|
|
prop = {
|
|
type: prop
|
|
};
|
|
}
|
|
|
|
var _prop = prop,
|
|
observer = _prop.observer;
|
|
|
|
prop.observer = function () {
|
|
if (observer) {
|
|
if (typeof observer === 'string') {
|
|
observer = this[observer];
|
|
}
|
|
|
|
observer.apply(this, arguments);
|
|
}
|
|
|
|
this.set();
|
|
};
|
|
|
|
props[key] = prop;
|
|
});
|
|
} |