Blame view

src/wxcomponents/vant/mixins/observer/index.js 608 Bytes
289f85d9e   Adam   提交
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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;
      }
  }