nested-props.html 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  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 : {{a.b.c}}</h1>
  10. <h2>a.c : {{a.c}}</h2>
  11. <h3>Computed property that concats the two: {{d}}</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. <script>
  16. var Demo = Seed.ViewModel.extend({
  17. properties: {
  18. one: function () {
  19. this.a = {
  20. c: 1,
  21. b: {
  22. c: 'one'
  23. }
  24. }
  25. },
  26. two: function () {
  27. this.a.b = {
  28. c: 'two'
  29. }
  30. this.a.c = 2
  31. },
  32. three: function () {
  33. this.a.b.c = 'three'
  34. this.a.c = 3
  35. },
  36. d: {get: function () {
  37. return (this.a.b.c + this.a.c) || ''
  38. }}
  39. }
  40. })
  41. var app = new Demo({ el: document.body })
  42. </script>
  43. </body>
  44. </html>