Skip to content

Commit

Permalink
增强checkbox
Browse files Browse the repository at this point in the history
  • Loading branch information
yuanhongbo committed Apr 7, 2017
1 parent a10ecfd commit b4a8ed3
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
<body>
<div id="demo">
<p>
<input type="text" v-model="desc"/>
<textarea v-model="desc"></textarea>
</p>
<p>
<input type="text" v-model="user.name"/>
Expand Down Expand Up @@ -55,7 +55,7 @@
descText: "<span>It's text</span>",
descHtml: "<span>It's HTML</span>",
province: 'cq',
hobbits: ['soccer'],
hobbits: '',
gender: 'male',
user: {
name: 'Juven'
Expand Down
5 changes: 5 additions & 0 deletions mvvm.js
Original file line number Diff line number Diff line change
Expand Up @@ -314,6 +314,11 @@ var Compiler = (function () {
});
},
_processModel4Checkbox: function(vm, node, exp, val){
if (!Array.isArray(val)) {
// 若传入的val不为数组类型时,则转换
val = !!val ? [].concat(val) : [];
this._setVMVal(vm, exp, val);
}
node.addEventListener('change', function(e){
var el = e.target,
newValue = e.target.value,
Expand Down

0 comments on commit b4a8ed3

Please sign in to comment.