前端 大屏 缩放方案1

<template>
  <div class="largescreen-pc">
    <div
      class="scaleDiv"
      style="position: absolute;margin-top:165px"
      :style="{
        width: width + 'px',
        height: height + 'px',
        transform: 'scale(' + zoomX + ',' + zoomY + ')'
      }"
    >
      <div class="gis-div-class">
        <!-- 解决使用transform scale 之后,地图点位错位的问题 -->
        <iframe
          style="visibility:hidden;overflow-x:auto;overflow-y:hidden"  onload="this.style.visibility='visible'"
          className="map_iframe"
          :src="curSrc"
          frameborder="0"
          width="100%"
          height="100%"
          scrolling="no"
        ></iframe>
        <!--<dataV></dataV>-->
      </div>
    </div>
  </div>
</template>

<script>
import dataV from "./dataV.vue";
export default {
  name: "largescreen",
  components: {
    dataV
  },
  data() {
    return {
      curSrc: `./dataV`,
      page: {
        width: 4320,
        height: 1620
      },
      zoomX: 1,
      zoomY: 1,
      width: 4320,
      height: 1620,
      curData: "",
      curNewDate: "",
      clockTimer: null,
      dataTimer: null
    };
  },
  watch: {},
  created() {
    window.addEventListener("resize", this.handleResize);
    this.handleResize();
  },
  mounted() {
    console.log('window.location.pathname', window.location.pathname)
    console.log('window.location.origin', window.location.origin)
    this.dataTimer = setInterval(() => {
      this.curData = this.dateStrForma();
    }, 1000 * 60 * 30);
    this.curData = this.dateStrForma();
    this.clock();
    this.clockTimer = setInterval(() => {
      this.clock();
    }, 1000);
  },

  methods: {
    dateStrForma() {
      var nowDate = new Date();
      var year = nowDate.getFullYear();
      var month =
        nowDate.getMonth() + 1 < 10
          ? "0" + (nowDate.getMonth() + 1)
          : nowDate.getMonth() + 1;
      var day =
        nowDate.getDate() < 10 ? "0" + nowDate.getDate() : nowDate.getDate();
      var dateStr = year + "." + month + "." + day;
      return dateStr;
    },
    clock() {
      var oDate = new Date(); //创建日期对象
      this.curNewDate =
        oDate.getHours() +
        ":" +
        (oDate.getMinutes() > 9
          ? oDate.getMinutes()
          : `0${oDate.getMinutes()}`) +
        ":" +
        (oDate.getSeconds() > 9
          ? oDate.getSeconds()
          : `0${oDate.getSeconds()}`);
    },
    handleResize(event) {
      if (!this.page.width) {
        return;
      }
      let fullWidth = document.documentElement.clientWidth;
      let fullHeight = document.documentElement.clientHeight;
      let rateWidth = fullWidth / this.width;
      let rateHeight = fullHeight / this.height;
      let useRate = rateWidth;
      if (rateWidth > rateHeight) {
        useRate = rateHeight;
      }
      this.zoomX = useRate;
      this.zoomY = useRate;
    }
  },
  destroyed() {
    window.removeEventListener("resize", this.handleResize);
    if (this.clockTimer) {
      clearInterval(this.clockTimer);
    }
    if (this.dataTimer) {
      clearInterval(this.dataTimer);
    }
  }
};
</script>

<style lang="scss" scoped>
.img-bottom-class {
  background: url("./largeImg/imgbottom.png");
  background-size: 100% 100%;
  background-repeat: no-repeat;
  position: absolute;
  bottom: 0px;
  height: 81px;
  width: 972px;
  z-index: 9;
}
.largescreen-pc {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  user-select: none;
  background: #060606;
  .gis-div-class {
    height: calc(100% - 1px);
    position: relative;
  }

  .top-div {
    text-align: center;
    background: url("./largeImg/imgtitlebig.png");
    background-size: 100% 100%;
    background-repeat: no-repeat;
    height: 162px;
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-content: center;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 100px 70px #071531;
    .top-span {
      font-size: 64px;
      font-family: PangMenZhengDao;
      font-weight: 400;
      color: #ccf3ff;
    }
  }
}
.ring-top-text {
    position: absolute;
    right: 60px;
    color: #72bbff;
    width: 500px;
  }
  .top-text-col {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: baseline;
    justify-content: center;

    .el-col:nth-child(2) {
      font-size: 18px;
      font-family: Microsoft YaHei;
      font-weight: 400;
      color: #72bbff;
    }
    .el-col:first-child {
      font-family: PangMenZhengDao;
      font-weight: 400;
      color: #72bbff;
      font-size: 24px;
    }
    .el-col {
      //   text-align: right;
    }
    .el-col:last-child {
      font-size: 48px;
      font-family: PangMenZhengDao;
      font-weight: 400;
      color: #ffffff;
    }
  }
.scaleDiv {
  // background-image: url('../../assets/images/bg.png');
  width: 1920px;
  height: 1080px;
  background-size: 100% 100%;
  position: relative;
  transform-origin: center center;
  // transform-origin: 0 0;

  background: #060606;

  // position: fixed;
}
</style>

// 常用字体适应
option && this.myChartBaoj.setOption(option);
window.addEventListener("resize", () => {
  this.refreshChart();
});
refreshChart() {
  // if (!this.myChart) return;=
  this.myChartBaoj.resize();=
  this.setFontOption();
},
setFontOption() {
 console.log("重绘了");
 let obj = {
   tooltip: {
     textStyle: {
       fontSize: fontSize(18),
     },
   },
   xAxis: [
     {
       axisLabel: {
         fontSize: fontSize(11),
         fontStyle: "normal",
         fontWeight: "bold",
       },
     },
   ],
   yAxis: [
     {
       axisLabel: {
         fontSize: fontSize(12),
         fontStyle: "normal",
       },
     },
   ],
 }
 this.myChartBaoj.setOption(obj);
},
前端大屏适配的代码可以参考以下示例,其中使用了CSS3的媒体查询和百分比布局来实现适配: ```html <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>前端大屏适配示例</title> <style> /* 默认样式 */ * { margin: 0; padding: 0; } /* 大屏幕样式 */ @media screen and (min-width: 1024px) { /* 设置页面宽度为100% */ body { width: 100%; } /* 设置页面主体部分宽度为80% */ .main { width: 80%; margin: 0 auto; } /* 设置页面元素的字体大小为2em */ h1, p { font-size: 2em; } /* 设置图片宽度为50% */ img { width: 50%; } } /* 小屏幕样式 */ @media screen and (max-width: 1023px) { /* 设置页面宽度为100% */ body { width: 100%; } /* 设置页面主体部分宽度为90% */ .main { width: 90%; margin: 0 auto; } /* 设置页面元素的字体大小为1em */ h1, p { font-size: 1em; } /* 设置图片宽度为100% */ img { width: 100%; } } </style> </head> <body> <div class="main"> <h1>前端大屏适配示例</h1> <p>这是一个前端大屏适配的示例,通过使用CSS3的媒体查询和百分比布局来实现。</p> <img src="example.jpg" alt="示例图片"> </div> </body> </html> ``` 在上述代码中,通过设置 @media 查询来实现不同屏幕尺寸下的样式设置。在大屏幕下,设置了页面宽度为100%、页面主体部分宽度为80%、页面元素字体大小为2em、图片宽度为50%等样式。在小屏幕下,设置了页面宽度为100%、页面主体部分宽度为90%、页面元素字体大小为1em、图片宽度为100%等样式。通过这种方式,可以实现前端大屏适配。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值