父组件vue
<v-sub @returnDate=returnDate :backGround=backGround></v-sub>
import vSub from "../../../components/v-sub.vue"
export default {
components:{
vSub
},
data() {
return {
backGround:"#000"
}
},
methods: {
returnDate(e){
console.log("接收到的值==>>"+e)
}
}
}复制代码
<device ref="device" :stoId="storeId" v-show="active == 'device'">
</device>
<battery ref="battery" :stoId="storeId" v-show="active == 'battery'">
</battery>
import device from './components/device.vue'
import battery from './components/battery.vue'
export default {
components: {
device,
battery
},
data() {
return {
storeId: null, // 参数storeId
active: 'device' // 切换tab
}
},复制代码
子组件this
<template>
<view class="content" :style="[{background:backGround}]">
<button @tap="passValue">点击传值</button>
</view>
</template>
<script>
export default {
props:{
backGround:{
type:String,
default:"#fff"
}
},
methods:{
passValue(){
this.$emit("returnDate","yoyoyo")
}
}
}
</script>
<style>
.content{
width: 400upx;
height: 400upx;
}
</style>复制代码
子类接收父类的数据,就会用到propsspa
子组件给父组件传值首先在子类组件定义事件3d
父组件:code
子组件component
子组件cdn
父组件blog
若本号内容有作得不到位的地方(好比:涉及版权或其余问题),请及时联系咱们进行整改便可,会在第一时间进行处理。事件
这是一个有质量,有态度的博客ip