| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263 |
- <!DOCTYPE html>
- <html lang="en">
- <head>
- <title></title>
- <meta charset="utf-8">
- <script src="../dist/seed.js"></script>
- </head>
- <body>
- <h1>a.b.c : <span sd-text="a.b.c"></span></h1>
- <h2>a.c : <span sd-text="a.c"></span></h2>
- <h3>Computed property that concats the two: <span sd-text="d"></span></h3>
- <button sd-on="click:one">one</button>
- <button sd-on="click:two">two</button>
- <button sd-on="click:three">three</button>
- <p><input sd-value="msg"></p>
- <script>
- seed.config({debug: true})
- var data = {
- c: 0,
- b: {
- c: 'zero'
- }
- }
- var Demo = seed.ViewModel.extend({
- init: function () {
- this.msg = 'Yoyoyo'
- // example of async compilation
- var vm = this
- vm.$wait()
- setTimeout(function () {
- vm.a = data
- vm.$ready()
- }, 30)
- },
- props: {
- one: function () {
- this.a = {
- c: 1,
- b: {
- c: 'one'
- }
- }
- },
- two: function () {
- this.a.b = {
- c: 'two'
- }
- this.a.c = 2
- },
- three: function () {
- this.a.b.c = 'three'
- this.a.c = 3
- },
- d: {get: function (ctx) {
- return (ctx.vm.msg + this.a.b.c + this.a.c) || ''
- }}
- }
- })
- var app = new Demo({ el: document.body })
- </script>
- </body>
- </html>
|