1. 程式人生 > >vue 組件 模板input雙向數據數據

vue 組件 模板input雙向數據數據

inpu tms 組件 data msg tle pro scrip 模板


<!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/[email protected]/dist/vue.js"></script>
<script >
// 註冊
Vue.component(‘child‘, {
props: [‘myMessage‘],
template: ‘<span>{{ myMessage }}</span>‘
})

// 創建根實例
new Vue({
el: ‘#example‘,
data:{
parentMsg:‘‘
}
})
</script>
</html>

vue 組件 模板input雙向數據數據