<template>
    <nav class="channel_nav back100">
        <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: 60px;
    width: 1200px;
    margin: 0 auto;
    background-image: url(@/public/img/5.png);
    margin-top: 40px;

    .channel_nav_a {
        float: left;
        height: 60px;
        line-height: 60px;
        color: #255590;
        font-size: 20px;
        margin: 0px 19px;
        font-weight: bold;
    }

    >.channel_nav_a:nth-of-type(1) {
        color: #fff;
        width: 230px;
        padding-left: 50px;
        box-sizing: border-box;
        margin-left:0;
        margin-right: 0;
    }
}
.back100 {
    background-size: 100% 100%;
    background-repeat: no-repeat;
}
</style>