标签:pre code asc mes new color 绑定 v-model input
1.给子组件传递属性,例如:
Vue.component(‘child‘,{ props:[‘message‘], template:‘<span>{{ message }}</span>‘ }); new Vue({ el: ‘#proptest‘ }) //HTML <div id= "proptest"> <child message="hello!"></child> </div> //show <div id= "proptest"> <span>hello</span> </div>
2.动态prop属性:
<div id= "proptest">
<!-- v-model表单输入绑定 input和textarea标签用-->
<input v-model="parrentMsg">
<br>
<div >
<!--my-message 绑定到父组件属性 -->
<child :my-message="parrentMsg"></child>
</div>
</div>
<script type="text/javascript">
Vue.component(‘child‘,{
props:[‘myMessage‘],
template:‘<span>{{ myMessage }}</span>‘
});
new Vue({
el: ‘#proptest‘,
data:{
"parrentMsg":"hello"
}
})
</script>
标签:pre code asc mes new color 绑定 v-model input
原文地址:https://www.cnblogs.com/liuyinlei/p/9378026.html