一、父组件向子组件传递数据(props)
1.parent
<template>
<view>
<child :parentData="parentData"></child>
</view>
</template>
<script>
import child from "@/components/example/child.vue"
export default {
components: {
child: child
},
data() {
return {
parentData: '我是父组件中的数据',
}
}
}
</script>
<style>
</style>
2.child
<template>
<view>
<text>{
{
parentData}}</text>
</view>
</template>
<script>
export default{
data(){
return{
}
},
props:{
parentData:{
type:String