add todo-store demo

This commit is contained in:
dntzhang 2017-05-08 16:30:12 +08:00
parent 7238b54e67
commit f4e1859c93
7 changed files with 1074 additions and 801 deletions

View File

@ -1,13 +0,0 @@
import Omi from '../../src/index.js';
class List extends Omi.Component {
constructor(data) {
super(data)
}
render () {
return ` <ul> {{#items}} <li>{{.}}</li> {{/items}}</ul>`
}
}
export default List;

View File

@ -0,0 +1,9 @@
import Omi from '../../src/index.js';
class List extends Omi.Component {
render () {
return ` <ul> <li o-repeat="item in items">{{item}}</li></ul>`
}
}
export default List;

View File

@ -3,15 +3,16 @@ export default {
items: ["omi", "store"]
},
methods: {
install:function(){
},
add: function (value) {
this.data.items.push(value)
this.data.length = this.data.items.length
this.update()
},
clear: function () {
this.data.items.length = 0
this.data.length = 0
this.update()
}
}

View File

@ -1,7 +1,7 @@
import Omi from '../../src/index.js';
import List from './list.js';
Omi.makeHTML('List', List);
Omi.tag('list', List);
class Todo extends Omi.Component {
constructor(data) {
@ -42,8 +42,8 @@ class Todo extends Omi.Component {
render () {
return `<div>
<h3>TODO</h3>
<button onclick="clear">Clear</button>
<List name="list" data="$store.data" />
<button onclick="clear">Clear</button>
<list name="list" data="$store.data"></list>
<form onsubmit="add" >
<input type="text" onchange="handleChange" value="{{text}}" />
<button>Add #{{length}}</button>