index.js 654 B

123456789101112131415161718192021
  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 = {
  12. type: prop
  13. };
  14. }
  15. prop.observer = watch[key];
  16. props[key] = prop;
  17. }
  18. });
  19. options.properties = props;
  20. }
  21. }