<template>
    <nav class="channel_nav clearfix">
        <a class="channel_nav_a" href="javascript:(void)" title="title">{{ title }}</a>
        <span v-for="(item,index) in titleData">
            <NuxtLink :to="{ path: `/${item.aLIas_pinyin}/list-1.html`}" class="channel_nav_a" v-if="index<=7">{{ item.alias }}</NuxtLink>
        </span>
    </nav>
</template>

<script setup>
//1.设置组件数据 start---------------------------------------->
//子导航
const props = defineProps({
    titleData:Array,
    pinyinid:Number
});

//获取当前url路径
const route = useRoute();
//获得当前的完整路径
const fullPath = route.path;
const segments = fullPath.split('/'); 
const targetSegment = segments[1]; 
//1.设置组件数据 end---------------------------------------->

//2.设置组件标题 start ---------------------------------------->
const title = ref("")
async function getPageData() {
    const mkdata =  await requestDataPromise('/web/getOneWebsiteCategory', {
        method: 'GET',
        query: {
            'catid': props.pinyinid,
        },
    });
    if(mkdata.code == 200){
        title.value = mkdata.data.alias;
    }else{
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
        console.log("错误位置：获取二级标题")
        console.log("后端错误反馈：",mkdata.message)
        console.log("SSR waring ---------- SSR waring ---------- SSR waring ---------->")
    }
}
getPageData();
//2.设置组件标题 end ---------------------------------------->
</script>

<style lang="less" scoped>
.channel_nav {
    height: 42px;
    border-bottom: solid 3px #004564;
    margin-top: 30px;
    width: 1200px;
    margin: 0 auto;
    margin-top: 30px;

    .channel_nav_a {
        float: left;
        height: 42px;
        line-height: 42px;
        color: #333;
        font-size: 18px;
        margin-left: 30px;
        font-weight: bold;
    }

    >.channel_nav_a:nth-of-type(1) {
        height: 42px;
        line-height: 42px;
        font-size: 30px;
        color: #fff;
        font-weight: bold;
        background: url(@/public/img/27.png) no-repeat right 0px;
        background-size: 100% 100%;
        padding: 0px 15px;
        margin: 1px 0px 10px 0px;
    }
}
</style>