vue 组件之间的通信-父组件给子组件传递数据
下面是一个父组件给子组件传递数据的例子:
<!DOCTYPE html>
<html>
<head lang="en">
<meta charset="UTF-8">
<title></title>
</head>
<body>
<script src="../js/vue.js"></script>
<div id="app">
<child-cpn :message="message"></child-cpn>
</div>
<template id="childCpn">
<div>显示的信息:{{message}}</div>
</template>
<script>
let app=new Vue({
el:'#app',
data:{
message:'hello world'
},
components:{
'child-cpn':{
template:'#childCpn',
props:['message']
}
}
})
</script>
</body>
</html>
运行结果:

浙公网安备 33010602011771号