当前位置: 首页 > news >正文

上海浦东新区做网站广州专业网络推广公司

上海浦东新区做网站,广州专业网络推广公司,企业网站设计布局,做私彩网站多少钱1、scale方案 优点&#xff1a;使用scale适配是最快且有效的&#xff08;等比缩放&#xff09; 缺点&#xff1a; 等比缩放时&#xff0c;项目的上下或者左右是肯定会有留白的 实现步骤 <div className"screen-wrapper"><div className"screen"…

1、scale方案

在这里插入图片描述
优点:使用scale适配是最快且有效的(等比缩放)
缺点: 等比缩放时,项目的上下或者左右是肯定会有留白的

实现步骤

<div className="screen-wrapper"><div className="screen" id="screen"></div>
</div>
<script>
export default {
mounted() {// 初始化自适应  ----在刚显示的时候就开始适配一次handleScreenAuto();// 绑定自适应函数   ---防止浏览器栏变化后不再适配window.onresize = () => handleScreenAuto();
},
deleted() {window.onresize = null;
},
methods: {// 数据大屏自适应函数handleScreenAuto() {const designDraftWidth = 1920; //设计稿的宽度const designDraftHeight = 960; //设计稿的高度// 根据屏幕的变化适配的比例,取短的一边的比例const scale =(document.documentElement.clientWidth / document.documentElement.clientHeight) <(designDraftWidth / designDraftHeight)? (document.documentElement.clientWidth / designDraftWidth):(document.documentElement.clientHeight / designDraftHeight)// 缩放比例document.querySelector('#screen',).style.transform = `scale(${scale}) translate(-50%, -50%)`;}
}
}
</script>
/*除了设计稿的宽高是根据您自己的设计稿决定以外,其他复制粘贴就完事
*/  
.screen-root {height: 100%;width: 100%;.screen {display: inline-block;width: 1920px;  //设计稿的宽度height: 960px;  //设计稿的高度transform-origin: 0 0;position: absolute;left: 50%;top: 50%;}
}

如果你不想分别写html,js和css,那么你也可以使用v-scale-screen插件来帮你完成
使用插件参考:https://juejin.cn/post/7075253747567296548

2、使用dataV库,推荐使用

vue2版本:http://datav.jiaminghi.com/
vue3版本:https://datav-vue3.netlify.app/

<dv-full-screen-container>content
</dv-full-screen-container>

优点:方便,没有留白,铺满可视区

3、手写dataV的container容器

嫌麻还是用dataV吧
文件结构
在这里插入图片描述
index.vue

<template><div id="imooc-screen-container" :ref="ref"><template v-if="ready"><slot></slot></template></div>
</template><script>import autoResize from './autoResize.js'export default {name: 'DvFullScreenContainer',mixins: [autoResize],props: {options: {type: Object}},data() {return {ref: 'full-screen-container',allWidth: 0,allHeight: 0,scale: 0,datavRoot: '',ready: false}},methods: {afterAutoResizeMixinInit() {this.initConfig()this.setAppScale()this.ready = true},initConfig() {this.allWidth = this.width || this.originalWidththis.allHeight = this.height || this.originalHeightif (this.width && this.height) {this.dom.style.width = `${this.width}px`this.dom.style.height = `${this.height}px`} else {this.dom.style.width = `${this.originalWidth}px`this.dom.style.height = `${this.originalHeight}px`}},setAppScale() {const currentWidth = document.body.clientWidthconst currentHeight = document.body.clientHeightthis.dom.style.transform = `scale(${currentWidth / this.allWidth}, ${currentHeight / this.allHeight})`},onResize() {this.setAppScale()}}}
</script><style lang="less">#imooc-screen-container {position: fixed;top: 0;left: 0;overflow: hidden;transform-origin: left top;z-index: 999;}
</style>

autoResize.js

import { debounce, observerDomResize } from './util'export default {data () {return {dom: '',width: 0,height: 0,originalWidth: 0,originalHeight: 0,debounceInitWHFun: '',domObserver: ''}},methods: {async autoResizeMixinInit () {await this.initWH(false)this.getDebounceInitWHFun()this.bindDomResizeCallback()if (typeof this.afterAutoResizeMixinInit === 'function') this.afterAutoResizeMixinInit()},initWH (resize = true) {const { $nextTick, $refs, ref, onResize } = thisreturn new Promise(resolve => {$nextTick(e => {const dom = this.dom = $refs[ref]if (this.options) {const { width, height } = this.optionsif (width && height) {this.width = widththis.height = height}} else {this.width = dom.clientWidththis.height = dom.clientHeight}if (!this.originalWidth || !this.originalHeight) {const { width, height } = screenthis.originalWidth = widththis.originalHeight = height}if (typeof onResize === 'function' && resize) onResize()resolve()})})},getDebounceInitWHFun () {this.debounceInitWHFun = debounce(100, this.initWH)},bindDomResizeCallback () {this.domObserver = observerDomResize(this.dom, this.debounceInitWHFun)window.addEventListener('resize', this.debounceInitWHFun)},unbindDomResizeCallback () {this.domObserver.disconnect()this.domObserver.takeRecords()this.domObserver = nullwindow.removeEventListener('resize', this.debounceInitWHFun)}},mounted () {this.autoResizeMixinInit()},beforeDestroy () {const { unbindDomResizeCallback } = thisunbindDomResizeCallback()}
}

util/index.js

export function randomExtend (minNum, maxNum) {if (arguments.length === 1) {return parseInt(Math.random() * minNum + 1, 10)} else {return parseInt(Math.random() * (maxNum - minNum + 1) + minNum, 10)}
}export function debounce (delay, callback) {let lastTimereturn function () {clearTimeout(lastTime)const [that, args] = [this, arguments]lastTime = setTimeout(() => {callback.apply(that, args)}, delay)}
}export function observerDomResize (dom, callback) {const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserverconst observer = new MutationObserver(callback)observer.observe(dom, { attributes: true, attributeFilter: ['style'], attributeOldValue: true })return observer
}export function getPointDistance (pointOne, pointTwo) {const minusX = Math.abs(pointOne[0] - pointTwo[0])const minusY = Math.abs(pointOne[1] - pointTwo[1])return Math.sqrt(minusX * minusX + minusY * minusY)
}

// 看下面这个没有封装完善的
核心原理: 固定宽高比,采用缩放,一屏展示出所有的信息
在这里插入图片描述

在这里插入图片描述

<template><div class="datav_container" id="datav_container" :ref="refName"><template v-if="ready"><slot></slot></template></div>
</template><script>
import { ref, getCurrentInstance, onMounted, onUnmounted, nextTick } from 'vue'
import { debounce } from '../../utils/index.js'
export default {// eslint-disable-next-line vue/multi-word-component-namesname: 'Container',props: {options: {type: Object,default: () => {}}},setup(ctx) {const refName = 'container'const width = ref(0)const height = ref(0)const origialWidth = ref(0) // 视口区域const origialHeight = ref(0)const ready = ref(false)let context, dom, observerconst init = () => {return new Promise((resolve) => {nextTick(() => {// 获取domdom = context.$refs[refName]console.log(dom)console.log('dom', dom.clientWidth, dom.clientHeight)// 获取大屏真实尺寸if (ctx.options && ctx.options.width && ctx.options.height) {width.value = ctx.options.widthheight.value = ctx.options.height} else {width.value = dom.clientWidthheight.value = dom.clientHeight}// 获取画布尺寸if (!origialWidth.value || !origialHeight.value) {origialWidth.value = window.screen.widthorigialHeight.value = window.screen.height}console.log(width.value, height.value, window.screen, origialWidth.value, origialHeight.value)resolve()})})}const updateSize = () => {if (width.value && height.value) {dom.style.width = `${width.value}px`dom.style.height = `${height.value}px`} else {dom.style.width = `${origialWidth.value}px`dom.style.height = `${origialHeight.value}px`}}const updateScale = () => {// 计算压缩比// 获取真实视口尺寸const currentWidth = document.body.clientWidth // 视口实际显示区(浏览器页面实际显示的)const currentHeight = document.body.clientHeightconsole.log('浏览器页面实际显示', currentWidth, currentHeight)// 获取大屏最终宽高const realWidth = width.value || origialWidth.valueconst realHeight = height.value || origialHeight.valueconst widthScale = currentWidth / realWidthconst heightScale = currentHeight / realHeightdom.style.transform = `scale(${widthScale}, ${heightScale})`}const onResize = async (e) => {// console.log('resize', e)await init()await updateScale()}const initMutationObserver = () => {const MutationObserver = window.MutationObserver || window.WebKitMutationObserver || window.MozMutationObserverobserver = new MutationObserver(onResize)observer.observe(dom, {attributes: true,attributeFilter: ['style'],attributeOldValue: true})}const removeMutationObserver = () => {if (observer) {observer.disconnect()observer.takeRecords()observer = null}}onMounted(async () => {ready.value = falsecontext = getCurrentInstance().ctxawait init()updateSize()updateScale()window.addEventListener('resize', debounce(onResize, 100))initMutationObserver()ready.value = true})onUnmounted(() => {window.removeEventListener('resize', debounce(onResize, 100))removeMutationObserver()})return {refName,ready}}
}
</script><style lang="scss" scoped>
.datav_container {position: fixed;top: 0;left: 0;transform-origin: left top;overflow: hidden;z-index: 999;
}
</style>

在使用Container组件的时候,这样用

<Container :options="{ width: 3840, height: 2160 }"><div class="test">111</div>
</Container> 

传入你的大屏的分辨率options

// 获取大屏真实尺寸

// 获取dom
dom = context.$refs[refName]
// 获取大屏真实尺寸
if (ctx.options && ctx.options.width && ctx.options.height) {width.value = ctx.options.widthheight.value = ctx.options.height
} else {width.value = dom.clientWidthheight.value = dom.clientHeight
}

// 获取画布尺寸

if (!origialWidth.value || !origialHeight.value) {origialWidth.value = window.screen.widthorigialHeight.value = window.screen.height
}

// 定义更新size方法

 const updateSize = () => {if (width.value && height.value) {dom.style.width = `${width.value}px`dom.style.height = `${height.value}px`} else {dom.style.width = `${origialWidth.value}px`dom.style.height = `${origialHeight.value}px`}
}

// 设置压缩比

 const updateScale = () => {// 计算压缩比// 获取真实视口尺寸const currentWidth = document.body.clientWidth // 视口实际显示区(浏览器页面实际显示的)const currentHeight = document.body.clientHeightconsole.log('浏览器页面实际显示', currentWidth, currentHeight)// 获取大屏最终宽高const realWidth = width.value || origialWidth.valueconst realHeight = height.value || origialHeight.valueconst widthScale = currentWidth / realWidthconst heightScale = currentHeight / realHeightdom.style.transform = `scale(${widthScale}, ${heightScale})`
}

文章转载自:
http://diosmosis.rdbj.cn
http://racehorse.rdbj.cn
http://snell.rdbj.cn
http://boldly.rdbj.cn
http://formalistic.rdbj.cn
http://interamnian.rdbj.cn
http://approximation.rdbj.cn
http://paddyfield.rdbj.cn
http://superabundant.rdbj.cn
http://dissertation.rdbj.cn
http://underivative.rdbj.cn
http://hydrosoma.rdbj.cn
http://tabes.rdbj.cn
http://jet.rdbj.cn
http://helmsman.rdbj.cn
http://crenelle.rdbj.cn
http://infer.rdbj.cn
http://diglyceride.rdbj.cn
http://ragged.rdbj.cn
http://claustrophobic.rdbj.cn
http://carbonari.rdbj.cn
http://lupulin.rdbj.cn
http://eec.rdbj.cn
http://keister.rdbj.cn
http://rhytidectomy.rdbj.cn
http://tsangpo.rdbj.cn
http://frons.rdbj.cn
http://tropology.rdbj.cn
http://bicommunal.rdbj.cn
http://symplesite.rdbj.cn
http://cinerama.rdbj.cn
http://lamblike.rdbj.cn
http://incoordination.rdbj.cn
http://suberose.rdbj.cn
http://elder.rdbj.cn
http://psychopharmacologist.rdbj.cn
http://awn.rdbj.cn
http://dankness.rdbj.cn
http://entomolite.rdbj.cn
http://bullace.rdbj.cn
http://atwain.rdbj.cn
http://crassly.rdbj.cn
http://athonite.rdbj.cn
http://misdo.rdbj.cn
http://radiocardiogram.rdbj.cn
http://marc.rdbj.cn
http://anecdotical.rdbj.cn
http://entrant.rdbj.cn
http://zilog.rdbj.cn
http://peccancy.rdbj.cn
http://henotheism.rdbj.cn
http://portfire.rdbj.cn
http://overcall.rdbj.cn
http://waif.rdbj.cn
http://watercolour.rdbj.cn
http://catecheticel.rdbj.cn
http://cupboard.rdbj.cn
http://cryostat.rdbj.cn
http://unsubstantial.rdbj.cn
http://esthetics.rdbj.cn
http://winterize.rdbj.cn
http://preconcerted.rdbj.cn
http://isomerism.rdbj.cn
http://tum.rdbj.cn
http://lifespring.rdbj.cn
http://inclusively.rdbj.cn
http://polysynapse.rdbj.cn
http://cytotrophy.rdbj.cn
http://soleus.rdbj.cn
http://immolation.rdbj.cn
http://coquille.rdbj.cn
http://emma.rdbj.cn
http://playscript.rdbj.cn
http://conmanship.rdbj.cn
http://ponceau.rdbj.cn
http://anklebone.rdbj.cn
http://suspensive.rdbj.cn
http://resource.rdbj.cn
http://gravisphere.rdbj.cn
http://embosom.rdbj.cn
http://antiparasitic.rdbj.cn
http://anaesthetise.rdbj.cn
http://anchithere.rdbj.cn
http://bangladeshi.rdbj.cn
http://anamorphism.rdbj.cn
http://soundrec.rdbj.cn
http://zonetime.rdbj.cn
http://belowstairs.rdbj.cn
http://extract.rdbj.cn
http://seedling.rdbj.cn
http://campanulaceous.rdbj.cn
http://lactoprotein.rdbj.cn
http://corrector.rdbj.cn
http://dramalogue.rdbj.cn
http://parashoot.rdbj.cn
http://oncoming.rdbj.cn
http://codfish.rdbj.cn
http://artifactitious.rdbj.cn
http://windfirm.rdbj.cn
http://cuculliform.rdbj.cn
http://www.dt0577.cn/news/103556.html

相关文章:

  • 备案通过 网站打不开网站模板哪家好
  • 怎样突破网站设计瓶颈客户管理软件哪个好用
  • 宁波seo在线优化方案公司郑州seo竞价
  • 交通部基本建设质量监督总站网站seo方法
  • 博客用来做微网站惠州网站seo排名优化
  • 惠州网站建设如何河南企业网站建设
  • 深圳市建设工程造价站官网建站快车
  • 在韶关做网站如何做优化排名
  • 长沙网站建设0731上海有实力的seo推广咨询
  • 提供盐城网站开发搜索引擎优化包括哪些
  • 织梦网站怎么做新闻导航页百度招聘官网首页
  • 做网站哪个便宜google关键词优化
  • wordpress保存帖子数据昆明百度搜索排名优化
  • 湖南网站seo公司谷歌浏览器手机版官网下载
  • 做平台网站需要多少钱百度推广代理公司广州
  • 江苏省徐州市建设银行网站比百度好用的搜索软件手机版
  • 委托网站建设合同汕头百度推广公司
  • 网站公安局备案怎么做微网站建站平台
  • 东莞网站外包如何自己做推广
  • 建网站挣钱吗淮北网站建设
  • 赣州网页设计师培训seo链接优化
  • 大型公司网络搭建实例网站优化包括哪些内容
  • 网站建设普及型市场营销活动策划方案
  • 微信网站在线登录网页版自媒体135网站
  • 网站后台模板如何使用长尾关键词爱站网
  • 网站建设空间申请网销是什么工作好做吗
  • 微信小程序后端开发语言郑州网站优化外包顾问
  • 百度推广怎么做网站外贸网站哪个比较好
  • 公司以前做的免费网站太多_新网站搜索不到整站优化seo公司哪家好
  • 返利网站 帐如何做关键词优化哪家好