index.js 608 B

12345678910111213141516171819
  1. import { behavior } from './behavior';
  2. export function observe(vantOptions, options) {
  3. const { watch } = vantOptions;
  4. options.behaviors.push(behavior);
  5. if (watch) {
  6. const props = options.properties || {};
  7. Object.keys(watch).forEach(key => {
  8. if (key in props) {
  9. let prop = props[key];
  10. if (prop === null || !('type' in prop)) {
  11. prop = { type: prop };
  12. }
  13. prop.observer = watch[key];
  14. props[key] = prop;
  15. }
  16. });
  17. options.properties = props;
  18. }
  19. }