uniapp点击选中更改背景色,第二次点击直接跳转

 

 

直接上代码

    <view    id="index0" v-for="(item, index) in value.list" :key="index" class="text-item"  style="background-color: #fee3b3" :style="{ width: 'calc(100% / ' + value.showType + ')',background:seltitle==item.link?'#fee3b3':''}" @click="redirectTo(item.link)">
                <view class="text-item-img" v-if="value.selectedTemplate == 'imageNavigation' && item.imageUrl">
                    <image v-if="Number(item.imgWidth) >= Number(item.imgHeight)" :src="$util.img(item.imageUrl)" style="width: 70rpx;" mode="widthFix"></image>
                    <image v-else :src="$util.img(item.imageUrl)" :style="{ width: (Number(item.imgWidth) / Number(item.imgHeight)) * 70 + 'rpx' }" style="height: 70rpx;"></image>
                </view>

 

 

retuen

    data() {
        return { 
            pageWidth: '',
            seltitle:''
              };
    },

方法

 

 

    methods: {
        redirectTo(link) {
            if(this.seltitle == link){
                this.$util.diyRedirectTo(link);
            }
            this.seltitle=link;
            
            if (this.siteId) {
                link.site_id = this.siteId;
            }
            //this.$util.diyRedirectTo(link);
        },
}

 

posted @ 2023-04-18 16:19  79524795  阅读(31)  评论(0编辑  收藏  举报