<div class="left"> <div class="fulltrend" :class="{ full: flag1 }"> <trend class="trend" ref="trend2"> </trend> <div class="iconfont icon-expand-alt icon" @click="fullscreen1" v-if="!flag1" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen1" v-else ></div> </div> <div class="fullseller" :class="{ full: flag }"> <seller class="seller" ref="seller2"></seller> <div class="iconfont icon-expand-alt icon" @click="fullscreen" v-if="!flag" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen" v-else ></div> </div> </div> <div class="center"> <div class="fullmap" :class="{ full: flag5 }"> <Map class="map" ref="map2"></Map> <div class="iconfont icon-expand-alt icon" @click="fullscreen5" v-if="!flag5" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen5" v-else ></div> </div> <div class="fullrank" :class="{ full: flag2 }"> <rank class="rank" ref="rank2"></rank> <div class="iconfont icon-expand-alt icon" @click="fullscreen2" v-if="!flag2" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen2" v-else ></div> </div> </div>优化
时间: 2024-03-30 12:34:06 浏览: 60
这段代码是一个页面布局,其中包含了四个组件:trend、seller、Map和rank。每个组件都有一个全屏按钮和一个退出全屏按钮,点击全屏按钮可以将当前组件切换到全屏模式,点击退出全屏按钮可以将当前组件切换回原来的大小。优化的话,可以考虑将全屏按钮和退出全屏按钮的代码进行封装,减少重复代码的出现。同时,可以增加一些功能,例如点击全屏按钮之后自动隐藏其他组件,以便更好地浏览当前组件。
相关问题
<div class="left"> <div class="fulltrend" :class="{ full: flag1 }"> <trend class="trend" ref="trend2"> </trend> <div class="iconfont icon-expand-alt icon" @click="fullscreen1" v-if="!flag1" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen1" v-else ></div> </div> <div class="fullseller" :class="{ full: flag }"> <seller class="seller" ref="seller2"></seller> <div class="iconfont icon-expand-alt icon" @click="fullscreen" v-if="!flag" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen" v-else ></div> </div> </div> <div class="center"> <div class="fullmap" :class="{ full: flag5 }"> <Map class="map" ref="map2"></Map> <div class="iconfont icon-expand-alt icon" @click="fullscreen5" v-if="!flag5" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen5" v-else ></div> </div>优化后代码
<div class="left">
<div class="fulltrend" :class="{ full: flag1 }">
<trend class="trend" ref="trend2"></trend>
<div class="iconfont icon-expand-alt icon" @click="fullscreen1" v-if="!flag1"></div>
<div class="iconfont icon-compress-alt icon" @click="smallscreen1" v-else></div>
</div>
<div class="fullseller" :class="{ full: flag }">
<seller class="seller" ref="seller2"></seller>
<div class="iconfont icon-expand-alt icon" @click="fullscreen" v-if="!flag"></div>
<div class="iconfont icon-compress-alt icon" @click="smallscreen" v-else></div>
</div>
</div>
<div class="center">
<div class="fullmap" :class="{ full: flag5 }">
<Map class="map" ref="map2"></Map>
<div class="iconfont icon-expand-alt icon" @click="fullscreen5" v-if="!flag5"></div>
<div class="iconfont icon-compress-alt icon" @click="smallscreen5" v-else></div>
</div>
</div>
<div class="top"> <img src="@/assets/qiehuan_dark.png" alt="" v-if="theme == 'chalk'" @click="changetheme" /> <img src="@/assets/qiehuan_light.png" alt="" v-else @click="changetheme" /> <span>2019-01-01 00:00:00</span> </div> </div> <div class="main" ref="main"> <div class="left"> <div class="fulltrend" :class="{ full: flag1 }"> <trend class="trend" ref="trend2"> </trend> <div class="iconfont icon-expand-alt icon" @click="fullscreen1" v-if="!flag1" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen1" v-else ></div> </div>优化后代码
<div class="top">
<img
:src="theme == 'chalk' ? '@/assets/qiehuan_dark.png' : '@/assets/qiehuan_light.png'"
alt=""
@click="changetheme"
/>
<span>2019-01-01 00:00:00</span>
</div>
<div class="main" ref="main">
<div class="left">
<div class="fulltrend" :class="{ full: flag1 }">
<trend class="trend" ref="trend2"></trend>
<div class="iconfont icon-expand-alt icon" @click="fullscreen1" v-if="!flag1"></div>
<div class="iconfont icon-compress-alt icon" @click="smallscreen1" v-else></div>
</div>
</div>
</div>
阅读全文