nested-props.html 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <title></title>
  5. <meta charset="utf-8">
  6. <script src="../dist/seed.js"></script>
  7. </head>
  8. <body>
  9. <h1>a.b.c : <span sd-text="a.b.c"></span></h1>
  10. <h2>a.c : <span sd-text="a.c"></span></h2>
  11. <h3>Computed property that concats the two: <span sd-text="d"></span></h3>
  12. <button sd-on="click:one">one</button>
  13. <button sd-on="click:two">two</button>
  14. <button sd-on="click:three">three</button>
  15. <p><input sd-value="msg"></p>
  16. <script>
  17. seed.config({debug: true})
  18. var Demo = seed.ViewModel.extend({
  19. init: function () {
  20. this.msg = 'Yoyoyo' },
  21. props: {
  22. one: function () {
  23. this.a = {
  24. c: 1,
  25. b: {
  26. c: 'one'
  27. }
  28. }
  29. },
  30. two: function () {
  31. this.a.b = {
  32. c: 'two'
  33. }
  34. this.a.c = 2
  35. },
  36. three: function () {
  37. this.a.b.c = 'three'
  38. this.a.c = 3
  39. },
  40. d: {get: function () {
  41. return this.msg + (this.a.b.c || '') + (this.a.c || '')
  42. }}
  43. }
  44. })
  45. var app = new Demo({ el: document.body })
  46. </script>
  47. </body>
  48. </html>