4***@qq.com
4***@qq.com
  • 发布:2022-03-17 10:24
  • 更新:2022-11-04 10:39
  • 阅读:2122

uniapp,父组件传值给子组件,子组件获取不到props的值,连字符串也都无法接收到

分类:uni-app

父组件:

<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>
2022-03-17 10:24 负责人:无 分享
已邀请:
5***@qq.com

5***@qq.com

解决了吗

Anet

Anet

let tabArr= ref<string>("父组件传递的数据")

该问题目前已经被锁定, 无法添加新回复