changes
This commit is contained in:
parent
7fcb9b872d
commit
b3331413e7
|
@ -0,0 +1,51 @@
|
|||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="UTF-8">
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=edge">
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<title>Document</title>
|
||||
</head>
|
||||
<body>
|
||||
<!-- 数值从子组件传到父组件 -->
|
||||
<div id="app">
|
||||
<apps @btn_click="shower"></apps>
|
||||
<h1>{{num}}</h1>
|
||||
</div>
|
||||
<template id="tpl">
|
||||
<div>
|
||||
<h1>这是子组件{{dnum}}</h1>
|
||||
<button @click="Changes()">点击</button>
|
||||
</div>
|
||||
</template>
|
||||
</body>
|
||||
<script src="../../../JavaScript/vue.js"></script>
|
||||
<script>
|
||||
new Vue({
|
||||
el:"#app",
|
||||
data:{
|
||||
num:0
|
||||
},
|
||||
methods:{
|
||||
shower(val){
|
||||
this.num="这是父组件"+val
|
||||
}
|
||||
},
|
||||
components:{
|
||||
'apps':{
|
||||
template:"#tpl",
|
||||
data(){
|
||||
return {
|
||||
dnum:"HelloVueComponents"
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
Changes(){
|
||||
this.$emit("btn_click",this.dnum)
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
})
|
||||
</script>
|
||||
</html>
|
Loading…
Reference in New Issue