初始化(包含登录模块)
This commit is contained in:
1
wxcomponents/vant/mixins/observer/behavior.d.ts
vendored
Normal file
1
wxcomponents/vant/mixins/observer/behavior.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare const behavior: string;
|
||||
14
wxcomponents/vant/mixins/observer/behavior.js
Normal file
14
wxcomponents/vant/mixins/observer/behavior.js
Normal file
@@ -0,0 +1,14 @@
|
||||
export const behavior = Behavior({
|
||||
methods: {
|
||||
set(data, callback) {
|
||||
return new Promise(resolve => {
|
||||
this.setData(data, () => {
|
||||
if (callback && typeof callback === 'function') {
|
||||
callback.call(this);
|
||||
}
|
||||
resolve();
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
1
wxcomponents/vant/mixins/observer/index.d.ts
vendored
Normal file
1
wxcomponents/vant/mixins/observer/index.d.ts
vendored
Normal file
@@ -0,0 +1 @@
|
||||
export declare function observe(vantOptions: any, options: any): void;
|
||||
19
wxcomponents/vant/mixins/observer/index.js
Normal file
19
wxcomponents/vant/mixins/observer/index.js
Normal file
@@ -0,0 +1,19 @@
|
||||
import { behavior } from './behavior';
|
||||
export function observe(vantOptions, options) {
|
||||
const { watch } = vantOptions;
|
||||
options.behaviors.push(behavior);
|
||||
if (watch) {
|
||||
const props = options.properties || {};
|
||||
Object.keys(watch).forEach(key => {
|
||||
if (key in props) {
|
||||
let prop = props[key];
|
||||
if (prop === null || !('type' in prop)) {
|
||||
prop = { type: prop };
|
||||
}
|
||||
prop.observer = watch[key];
|
||||
props[key] = prop;
|
||||
}
|
||||
});
|
||||
options.properties = props;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user