一、父组件向子组件传递数据
1 <template> 2 <view class="container"> 3 <view class="child"> hi {{showModal}}</view> 4 </view> 5 </template> 6 7 <script> 8 export default { 9 props: { 10 showModal: { 11 type: String, 12 default: 'hello' 13 } 14 }, 15 16 data() { 17 return { 18 19 }; 20 } 21 } 22 </script> 23 24 <style> 25 26 </style>
1 <template> 2 <view> 3 <child :showModal="showModal"></child> 4 </view> 5 </template> 6 7 <script> 8 import child from "../../components/child.vue" 9 10 export default { 11 components:{ 12 child 13 }, 14 data() { 15 return { 16 showModal:" parent say" 17 }; 18 } 19 } 20 </script> 21 22 <style> 23 24 </style>