console
Yox.filter("JSON_stringify", JSON.stringify);
let app = new Yox({
el: "#app",
template: `
<div>
<h3>{{version}}</h3>
<div>
{{#each list:index}}
<div>
{{form.username.value}}
<Input value="{{form.username.value}}"
on-change="_change2($event, $data, index, 'form.username')"
on-keyup="_keyup($event, $data)"
/>
</div>
{{/each}}
</div>
</div>
`,
data(){
return {
version: Yox.version,
current: 0,
list: [
{
form: {
username: {
value: "111111"
}
},
},
{
form: {
username: {
value: "222222"
}
},
},
{
form: {
username: {
value: "333333"
}
},
}
]
}
},
events: {
},
methods: {
_change1: function(event, data, index, path){
console.log(JSON.stringify(data))
var item = this.copy(this.get(`list.${index}`), true);
item = _.update(item, path, function (prop) {
return _.merge(prop, data);
})
console.log(JSON.stringify(item))
this.set(`list.${index}`, item)
},
_change2: function(event, data, index, path){
console.log(JSON.stringify(data))
var item = this.copy(this.get(`list.${index}`), true);
Yox.object.set( item, path, data)
console.log(JSON.stringify(item))
this.set(`list.${index}`, item)
},
_keyup(event, data){
console.log("_keyup>> no value", data)
}
}
});
<div id="app"></div>
<link rel="stylesheet" href="//unpkg.com/bell-ui@0.12.0/dist/bell-ui.css">
<script src="//unpkg.com/yox@1.0.0-alpha.121/dist/standard/dev/yox.js"></script>
<script src="//unpkg.com/bell-ui@0.12.0/dist/bell-ui.js"></script>
<script src="//unpkg.com/lodash@4.17.15/lodash.js"></script>