<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Title</title>
<script src="vue1.js"></script>
<!--<script src="vue-resource.js"></script>-->
</head>
<body>
<template id="sub">
<button @click="senddata">点击</button>
</template>
<div id="app">
<sub @send="getdata"></sub>
</div>
</body>
<script>
new Vue({
el:'#app',
methods:{
getdata:function(input){
alert(input);
}
},
components:{
'sub':{
template:'#sub',
methods:{
senddata:function(){
this.$emit('send','hello');
}
}
}
}
});
</script>
</html>
子组件向父组件传值
最新推荐文章于 2024-07-12 21:26:02 发布