-
Notifications
You must be signed in to change notification settings - Fork 476
/
Copy path12 use template.html
53 lines (50 loc) · 1.29 KB
/
12 use template.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE html>
<html lang="en">
<head>
<script type="text/javascript" src="vue.js"></script>
<meta charset="UTF-8">
<title>12</title>
</head>
<body>
<pre>
使用 < template >, 效果等同 < script x-template >
</pre>
<template id="template1">
<div>
<h2>{{title}}</h2>
<label for="username">Name:</label>
<input id="username" v-model="user.name">
<label for="useremail">Email:</label>
<input id="useremail" v-model="user.email">
<button v-on:click="save">Submit</button>
{{tmp1}}
<br> {{user.name}}
<br> {{user.email}}
<br>
</div>
</template>
<div id="app1">
</div>
<script>
var vm = new Vue({
el: '#app1',
template: "#template1",
data: function() {
return {
title: '使用者登录',
user: {
name: '台湾小凡',
email: '[email protected]'
},
tmp1: ''
}
},
methods: {
'save': function() {
this.tmp1 = 'clicked'
}
}
})
</script>
</body>
</html>