-
-
Notifications
You must be signed in to change notification settings - Fork 33.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Evan You
committed
Feb 13, 2014
1 parent
77ffd53
commit 75d200c
Showing
17 changed files
with
838 additions
and
972 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,51 +1,43 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Component</title> | ||
<meta charset="utf-8"> | ||
</head> | ||
<body> | ||
<div id="test"> | ||
<!-- v-component + v-with --> | ||
<div id="component-and-with" v-component="avatar" v-with="user"></div> | ||
|
||
<!-- custom element + v-with --> | ||
<avatar id="element-and-with" v-with="user"></avatar> | ||
|
||
<!-- v-with alone --> | ||
<div id="with" v-with="user">{{hi}} {{name}}</div> | ||
|
||
<!-- v-component alone --> | ||
<div id="component" v-component="simple"></div> | ||
|
||
<!-- custom element alone --> | ||
<simple id="element"></simple> | ||
</div> | ||
<script src="../../../dist/vue.js"></script> | ||
<script> | ||
|
||
Vue.config({debug: true}) | ||
|
||
Vue.component('avatar', { | ||
template: '{{hi}} {{name}}', | ||
ready: function () { | ||
console.log(JSON.stringify(this)) | ||
} | ||
}) | ||
|
||
Vue.component('simple', { | ||
template: '{{hi}} {{user.name}}' | ||
}) | ||
|
||
var app = new Vue({ | ||
el: '#test', | ||
data: { | ||
hi: '123', | ||
user: { | ||
name: 'Jack' | ||
} | ||
} | ||
}) | ||
</script> | ||
</body> | ||
</html> | ||
<div id="test"> | ||
<!-- v-component + v-with --> | ||
<div id="component-and-with" v-component="avatar" v-with="user"></div> | ||
|
||
<!-- custom element + v-with --> | ||
<avatar id="element-and-with" v-with="user"></avatar> | ||
|
||
<!-- v-with alone --> | ||
<div id="with" v-with="user">{{hi}} {{name}}</div> | ||
|
||
<!-- v-component alone --> | ||
<div id="component" v-component="simple"></div> | ||
|
||
<!-- custom element alone --> | ||
<simple id="element"></simple> | ||
</div> | ||
|
||
<script src="../../../dist/vue.js"></script> | ||
<script> | ||
|
||
Vue.config({debug: true}) | ||
|
||
Vue.component('avatar', { | ||
template: '{{hi}} {{name}}', | ||
ready: function () { | ||
console.log(JSON.stringify(this)) | ||
} | ||
}) | ||
|
||
Vue.component('simple', { | ||
template: '{{hi}} {{user.name}}' | ||
}) | ||
|
||
var app = new Vue({ | ||
el: '#test', | ||
data: { | ||
hi: '123', | ||
user: { | ||
name: 'Jack' | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,41 +1,33 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title>Repeated form elements</title> | ||
<meta charset="utf-8"> | ||
<script src="../../../dist/vue.js"></script> | ||
</head> | ||
<body> | ||
<form id="form"> | ||
<p v-repeat="items"> | ||
<input type="text" name="text{{$index}}" v-model="text"> | ||
</p> | ||
<button v-on="click: add" id="add">Add</button> | ||
<p id="texts">{{texts}}</p> | ||
</form> | ||
<script> | ||
var app = new Vue({ | ||
el: '#form', | ||
data: { | ||
items: [ | ||
{ text: "a" }, | ||
{ text: "b" } | ||
] | ||
}, | ||
methods: { | ||
add: function(e) { | ||
this.items.push({ text: "c" }) | ||
e.preventDefault() | ||
} | ||
}, | ||
computed: { | ||
texts: function () { | ||
return this.items.map(function(item) { | ||
return item.text | ||
}).join(",") | ||
} | ||
} | ||
}) | ||
</script> | ||
</body> | ||
</html> | ||
<form id="form"> | ||
<p v-repeat="items"> | ||
<input type="text" name="text{{$index}}" v-model="text"> | ||
</p> | ||
<button v-on="click: add" id="add">Add</button> | ||
<p id="texts">{{texts}}</p> | ||
</form> | ||
|
||
<script src="../../../dist/vue.js"></script> | ||
<script> | ||
var app = new Vue({ | ||
el: '#form', | ||
data: { | ||
items: [ | ||
{ text: "a" }, | ||
{ text: "b" } | ||
] | ||
}, | ||
methods: { | ||
add: function(e) { | ||
this.items.push({ text: "c" }) | ||
e.preventDefault() | ||
} | ||
}, | ||
computed: { | ||
texts: function () { | ||
return this.items.map(function(item) { | ||
return item.text | ||
}).join(",") | ||
} | ||
} | ||
}) | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,76 +1,68 @@ | ||
<!DOCTYPE html> | ||
<html lang="en"> | ||
<head> | ||
<title></title> | ||
<meta charset="utf-8"> | ||
<script src="../../../dist/vue.js"></script> | ||
</head> | ||
<body> | ||
<div id="normal"> | ||
<p v-text="one + ' ' + two.three + '!'"></p> | ||
<input id="one" v-model="one" name="one"> <input id="two" v-model="two.three" name="two"> | ||
<button v-on="click: this.one = 'clicked'">click</button> | ||
</div> | ||
<div id="lazy"> | ||
<p v-text="one + ' ' + two.three + '!'"></p> | ||
<form id="form"> | ||
<input v-model="one" name="three"> <input v-model="two.three" name="four"> | ||
</form> | ||
<button v-on="click: two.three = 'clicked'">click</button> | ||
</div> | ||
<div id="conditional"> | ||
<p>{{ok ? yesMsg : noMsg}}</p> | ||
<button v-on="click: ok = !ok" class="toggle">toggle</button> | ||
<button v-on="click: noMsg = 'Nah'" class="change">change</button> | ||
</div> | ||
<div id="attrs" data-test="hi {{msg}} ha"></div> | ||
<div id="html">html {{{html}}} work</div> | ||
<script> | ||
Vue.config({debug:true}) | ||
<div id="normal"> | ||
<p v-text="one + ' ' + two.three + '!'"></p> | ||
<input id="one" v-model="one" name="one"> <input id="two" v-model="two.three" name="two"> | ||
<button v-on="click: this.one = 'clicked'">click</button> | ||
</div> | ||
<div id="lazy"> | ||
<p v-text="one + ' ' + two.three + '!'"></p> | ||
<form id="form"> | ||
<input v-model="one" name="three"> <input v-model="two.three" name="four"> | ||
</form> | ||
<button v-on="click: two.three = 'clicked'">click</button> | ||
</div> | ||
<div id="conditional"> | ||
<p>{{ok ? yesMsg : noMsg}}</p> | ||
<button v-on="click: ok = !ok" class="toggle">toggle</button> | ||
<button v-on="click: noMsg = 'Nah'" class="change">change</button> | ||
</div> | ||
<div id="attrs" data-test="hi {{msg}} ha"></div> | ||
<div id="html">html {{{html}}} work</div> | ||
|
||
var normal = new Vue({ | ||
el: '#normal', | ||
data: { | ||
one: 'Hello', | ||
two: { | ||
three: 'World' | ||
} | ||
} | ||
}) | ||
<script src="../../../dist/vue.js"></script> | ||
<script> | ||
Vue.config({debug:true}) | ||
|
||
var lazy = new Vue({ | ||
el: '#lazy', | ||
lazy: true, | ||
data: { | ||
one: 'Hi', | ||
two: { | ||
three: 'Ho' | ||
} | ||
} | ||
}) | ||
var normal = new Vue({ | ||
el: '#normal', | ||
data: { | ||
one: 'Hello', | ||
two: { | ||
three: 'World' | ||
} | ||
} | ||
}) | ||
|
||
var conditional = new Vue({ | ||
el: '#conditional', | ||
data: { | ||
ok: true, | ||
yesMsg: 'YES', | ||
noMsg: 'NO' | ||
} | ||
}) | ||
var lazy = new Vue({ | ||
el: '#lazy', | ||
lazy: true, | ||
data: { | ||
one: 'Hi', | ||
two: { | ||
three: 'Ho' | ||
} | ||
} | ||
}) | ||
|
||
var attrs = new Vue({ | ||
el: '#attrs', | ||
data: { | ||
msg: 'ho' | ||
} | ||
}) | ||
var conditional = new Vue({ | ||
el: '#conditional', | ||
data: { | ||
ok: true, | ||
yesMsg: 'YES', | ||
noMsg: 'NO' | ||
} | ||
}) | ||
|
||
var html = new Vue({ | ||
el: '#html', | ||
data: { | ||
html: '<p>should</p> <a>probably</a>' | ||
} | ||
}) | ||
</script> | ||
</body> | ||
</html> | ||
var attrs = new Vue({ | ||
el: '#attrs', | ||
data: { | ||
msg: 'ho' | ||
} | ||
}) | ||
|
||
var html = new Vue({ | ||
el: '#html', | ||
data: { | ||
html: '<p>should</p> <a>probably</a>' | ||
} | ||
}) | ||
</script> |
Oops, something went wrong.