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>

原文地址:https://www.cnblogs.com/dianzan/p/8504103.html