您的位置:首页 > 产品设计 > UI/UE

vue组件3-父子组件props传参

2017-07-11 11:19 567 查看
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<ti
4000
tle>父子组件传参-props</title>
</head>
<script src="vue.js"></script>
<body>
<div id="app1">
<parent></parent>
</div>
<script>
Vue.component('child', {
// 声明 props
props: ['message'],
template: '<span>{{ message }}</span>'
})

//父子组件props传参子组件中可以使用props:['myMessage'],在父组件引用子组件时,使用my-message ="xx"

Vue.component('parent',{
    template:'<div><child message="我是子元素"></child></div>'
})
new Vue({
    el:"#app1"
})
</script>
</body>
</html>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: