父组件:
<template>
<view id="home">
<view class="mt50">
**<tab :data="tabArr" @change="_change"></tab>**
</view>
</view>
</template>
<script>
import {ref,reactive,toRefs} from 'vue';
import tab from '../../components/Tab/Tab.vue';
import test from '../../components/Tab/test.vue'
export default {
components: {
tab,
test
},
setup() {
let tabArr="父组件传递的数据";
//banner响应对象
let banner=reactive({
indicatorDots:true,
autoplay:true,
interval:2000,
duration:500,
images:[]
});
//功能入口
let entryArr=[
{name:'在线下单',icon:'../../static/images/buy.png',path:''},
{name:'运费查询',icon:'../../static/images/expense.png',path:''},
{name:'我的订单',icon:'../../static/images/myorder.png',path:''}
]
// tab切换
function _change(data){
console.log("打印子组件传回的数据",data)
}
return {
entryArr,
tabArr
}
},
}
</script>
2 个回复
5***@qq.com
解决了吗
Anet
let tabArr= ref<string>("父组件传递的数据")