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

那个网站可以做雪花特效网站推广seo

那个网站可以做雪花特效,网站推广seo,wordpress 热门文章,盐田做网站首先定义了一个名叫ScreenContainerOptions的组件,需要传的参数如下 export type ScreenContainerOptions {width?: string | numberheight?: string | numberscreenFit?: boolean // 是否开启屏幕自适应,不然会按比例显示 } 组件的主要代码如下 …

首先定义了一个名叫ScreenContainerOptions的组件,需要传的参数如下

export type ScreenContainerOptions = {width?: string | numberheight?: string | numberscreenFit?: boolean // 是否开启屏幕自适应,不然会按比例显示
}

组件的主要代码如下

onMounted(async () => {await initSize()updateSize()updateScale()window.addEventListener('resize', onResize)isReady.value = true // 执行完上面的方法后再渲染slot插槽
})// 初始化宽高
const initSize = () => {return new Promise((resolve) => {nextTick(() => {dom = refName.valueparentDom = refNameParent.value// 获取大屏的真实尺寸(不传值就是dom元素的宽高)widthRef.value = props.options?.width || dom.clientWidthheightRef.value = props.options?.height || dom.clientHeight// 获取屏幕尺寸,避免重复计算if (!screenWidthRef.value || !screenHeightRef.value) {screenWidthRef.value = window.screen.widthscreenHeightRef.value = window.screen.height}resolve(true)})})
}
// 更新宽高
const updateSize = () => {dom.style.width = `${widthRef.value || screenWidthRef.value}px`dom.style.height = `${heightRef.value || screenHeightRef.value}px`
}
// 更新缩放比例
const updateScale = () => {// window.innerWidth 获取当前展示区域的宽度const currentWidth = window.innerWidth// 获取大屏最终真实的宽度const realWidth = widthRef.value || screenWidthRef.value// 是否开启屏幕适配,不会按照比例const { screenFit } = props.options// 如果不想屏幕留白,而是自适应宽高的话let heightScale = 1// window.innerWidth 获取当前展示区域的宽度const currentHeight = window.innerHeight// 获取大屏最终真实的宽度const realHeight = heightRef.value || heightRef.valueif (screenFit) {heightScale = currentHeight / realHeight// if (parentDom) {//   parentDom.style.height = dom.style.height = `${window.innerHeight}px` // 父容器宽度设置为原屏幕的宽度// }}// 算出缩放比例并赋值// 只需要根据宽度计算即可const scale = currentWidth / realWidthdom && (dom.style.transform = `scale(${scale}, ${screenFit ? heightScale : 1})`) // 不开启screenFit的话高度不需要缩放if (parentDom) {parentDom.style.width = `${window.innerWidth}px` // 父容器宽度设置为原屏幕的宽度screenFit && (parentDom.style.height = `${window.innerHeight}px`) // 父容器宽度设置为原屏幕的宽度}
}// 浏览器resize事件触发回调
const onResize = async () => {await initSize()await nextTick()updateScale()
}

组件完整代码地址

https://github.com/jimchou-h/vue-study/blob/dev/src/components/ScreenContainer.vue

http://www.hengruixuexiao.com/news/41391.html

相关文章:

  • 网站按抓取手机软件贵阳优化营商环境 提升服务效能
  • 雄安政府网站建设杭州网络优化公司排名
  • 网站优化软件有哪些百度竞价代运营
  • 辽宁网站建设排名如何让百度搜索排名靠前
  • 网站制作模板北京24小时最新国际新闻
  • wordpress 邮件服务器青岛seo网站排名优化
  • 环保行业网站建设seo推广沧州公司电话
  • 新顶级域名做网站营销策划方案怎么写
  • flash 网站引导页百度关键词挖掘
  • 可以做长页的网站网络推广方案的基本思路
  • 做电脑系统哪个网站让顾客进店的100条方法
  • 辽宁高端网站建设深圳网站设计公司排行
  • 网站定制功能武汉it培训机构排名前十
  • 外贸网站建设及优化ppt快速排名点击工具
  • 公司网络规划的重要性网络推广优化培训
  • wordpress首页指定分类列表杭州网站seo推广
  • 网站开发必会语言啥是网络推广
  • 上海网站络公司百度关键词收录排名
  • wordpress大型站点网络营销策略名词解释
  • 网站开发亿玛酷专注4谷歌seo视频教程
  • 北京网站建设出名 乐云践新效果好的关键词如何优化
  • 英国做暧小视频网站seo推广价格
  • 赤坎手机网站建设公司移动优化课主讲:夫唯老师
  • 南陵网站建设各大搜索引擎网址
  • wordpress怎样添加二级导航菜单seo搜索价格
  • 网站做代练百度seo报价
  • 济南网站建设和维护百度账户代运营
  • 阜阳网站制作公司去哪找兰州模板网站seo价格
  • 做网站用电脑自带的游戏推广是干什么的
  • 工商局网站建设查不到网络关键词优化方法