vue 组件 模板input双向数据数据


<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Title of page</title>
</head>
<body>


<div id="example">
<input v-model="parentMsg">
<br>
<child v-bind:my-message="parentMsg"></child>

</div>

</body>
<script src="https://cdn.jsdelivr.net/npm/vue@2.5.13/dist/vue.js"></script>
<script >
// 注册
Vue.component('child', {
props: ['myMessage'],
template: '<span>{{ myMessage }}</span>'
})

// 创建根实例
new Vue({
el: '#example',
data:{
parentMsg:''
}
})
</script>
</html>

posted @ 2018-03-04 11:05  ThisCall  阅读(205)  评论(0编辑  收藏  举报