-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy path37practice.html
More file actions
58 lines (56 loc) · 1.37 KB
/
Copy path37practice.html
File metadata and controls
58 lines (56 loc) · 1.37 KB
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
54
55
56
57
58
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>Document</title>
</head>
<div id="app">
{{message}}
<cpn :number1="num1" :number2="num2"></cpn>
</div>
<template id="cpn">
<div>
<!-- 官方不推荐使用v-model绑定子组件的数据 用emit check 38-->
<input type="text" v-model="dnumber1">
<h2>props:{{number1}}</h2>
<h2>data number1:{{dnumber1}}</h2>
<input type="text" v-model="dnumber2">
<h2>props:{{number2}}</h2>
<h2>data number2:{{dnumber2}}</h2>
</div>
</template>
<body>
<script src="vue.js"></script>
<script>
//渐进开发
//创建了一个vue对象 参数是一个对象类型 {} 包含 如el,data 属性
//var let const 声明式编程 (数据与界面分离)
const app = new Vue({
el: '#app', // 用于要挂载的元素
data: {
message: 'first message',
num1: 1,
num2: 0
},
components: {
cpn: {
template: `#cpn`,
props: {
number1: Number,
number2: Number
},
data() {
return {
dnumber1: this.number1,
dnumber2: this.number2
}
}
}
}
})
</script>
</body>
</html>