index.js 1.0 KB

123456789101112131415161718192021222324252627282930
  1. "use strict";
  2. Object.defineProperty(exports, "__esModule", { value: true });
  3. var behavior_1 = require("./behavior");
  4. var props_1 = require("./props");
  5. function observe(vantOptions, options) {
  6. var watch = vantOptions.watch, computed = vantOptions.computed;
  7. options.behaviors.push(behavior_1.behavior);
  8. if (watch) {
  9. var props_2 = options.properties || {};
  10. Object.keys(watch).forEach(function (key) {
  11. if (key in props_2) {
  12. var prop = props_2[key];
  13. if (prop === null || !('type' in prop)) {
  14. prop = { type: prop };
  15. }
  16. prop.observer = watch[key];
  17. props_2[key] = prop;
  18. }
  19. });
  20. options.properties = props_2;
  21. }
  22. if (computed) {
  23. options.methods = options.methods || {};
  24. options.methods.$options = function () { return vantOptions; };
  25. if (options.properties) {
  26. props_1.observeProps(options.properties);
  27. }
  28. }
  29. }
  30. exports.observe = observe;