<div class="fullstock" :class="{ full: flag4 }"> <stock class="stock" ref="stock2"></stock> <div class="iconfont icon-expand-alt icon" @click="fullscreen4" v-if="!flag4" ></div> <div class="iconfont icon-compress-alt icon" @click="smallscreen4" v-else ></div> </div> </div> </div> </div> </template> <script> import { mapState } from "vuex"; import hot from "@/components/Hot.vue"; import seller from "@/components/Seller.vue"; import trend from "@/components/Trend.vue"; import Map from "@/components/Map.vue"; import rank from "@/components/Rank.vue"; import stock from "@/components/Stock.vue"; export default { name: "HomeView", 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"); }, fullscreen() { this.flag = true; this.$nextTick(() => { this.$refs.seller2.changesize(); }); }, fullscreen1() { this.flag1 = true; this.$nextTick(() => { this.$refs.trend2.screenAdapter(); }); }, fullscreen2() { this.flag2 = true; this.$nextTick(() => { this.$refs.rank2.screenAdapter(); }); }, fullscreen3() { this.flag3 = true; this.$nextTick(() => { this.$refs.hot2.screenAdapter(); }); }, fullscreen4() { this.flag4 = true; this.$nextTick(() => { this.$refs.stock2.screenAdapter(); }); }, fullscreen5() { this.flag5 = true; this.$nextTick(() => { this.$refs.map2.screenAdapter(); }); }, smallscreen() { this.flag = false; this.$nextTick(() => { this.$refs.seller2.changesize(); }); },优化后代码
时间: 2024-03-26 21:36:56 浏览: 64
vue添加class样式实例讲解
<div class="fullstock" :class="{ full: flag4 }">
<stock class="stock" ref="stock2"></stock>
<div class="iconfont icon-expand-alt icon" @click="fullscreen4" v-if="!flag4"></div>
<div class="iconfont icon-compress-alt icon" @click="smallscreen4" v-else></div>
</div>
</template>
<script>
import { mapState } from "vuex";
import hot from "@/components/Hot.vue";
import seller from "@/components/Seller.vue";
import trend from "@/components/Trend.vue";
import Map from "@/components/Map.vue";
import rank from "@/components/Rank.vue";
import stock from "@/components/Stock.vue";
export default {
name: "HomeView",
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");
},
fullscreen4() {
this.flag4 = true;
this.$nextTick(() => {
this.$refs.stock2.screenAdapter();
});
},
smallscreen4() {
this.flag4 = false;
this.$nextTick(() => {
this.$refs.stock2.screenAdapter();
});
},
},
};
</script>
阅读全文