<div class="fullseller" :class="{ full: flag }"> <seller class="seller" ref="seller2"></seller> <div class="iconfont icon-expand-alt icon" @click="full" v-if="!flag" ></div><div class="fullmap" :class="{ full: flag5 }"> <Map class="map" ref="map2"></Map> <div class="iconfont icon-expand-alt icon" @click="full5" v-if="!flag5" ></div>data() { return { flag: false, flag1: false, flag2: false, flag3: false, flag4: false, flag5: false, }; }, components: { hot, seller, trend, Map, rank, stock, }, methods: { changetheme() { this.$store.commit("tabtheme"); }, full() { this.flag = true; this.$nextTick(() => { this.$refs.seller2.changesize(); }); }, full1() { this.flag1 = true; this.$nextTick(() => { this.$refs.trend2.screenAdapter(); }); }, full2() { this.flag2 = true; this.$nextTick(() => { this.$refs.rank2.screenAdapter(); }); }, full3() { this.flag3 = true; this.$nextTick(() => { this.$refs.hot2.screenAdapter(); }); }, full4() { this.flag4 = true; this.$nextTick(() => { this.$refs.stock2.screenAdapter(); }); }, full5() { this.flag5 = true; this.$nextTick(() => { this.$refs.map2.screenAdapter(); }); },优化后代码
时间: 2024-03-26 11:36:50 浏览: 46
<div class="top">我的网页设计作业</div>
<div class="fullseller" :class="{ full: flags[0] }">
<seller class="seller" ref="seller2"></seller>
<div class="iconfont icon-expand-alt icon" @click="full(0)" v-if="!flags[0]"></div>
</div>
<div class="fullmap" :class="{ full: flags[5] }">
<Map class="map" ref="map2"></Map>
<div class="iconfont icon-expand-alt icon" @click="full(5)" v-if="!flags[5]"></div>
</div>
data() {
return {
flags: [false, false, false, false, false, false],
};
},
components: {
hot,
seller,
trend,
Map,
rank,
stock,
},
methods: {
changetheme() {
this.$store.commit("tabtheme");
},
full(index) {
this.flags[index] = true;
this.$nextTick(() => {
switch (index) {
case 0:
this.$refs.seller2.changesize();
break;
case 1:
this.$refs.trend2.screenAdapter();
break;
case 2:
this.$refs.rank2.screenAdapter();
break;
case 3:
this.$refs.hot2.screenAdapter();
break;
case 4:
this.$refs.stock2.screenAdapter();
break;
case 5:
this.$refs.map2.screenAdapter();
break;
default:
break;
}
});
},
}
阅读全文