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

weebly做网站建网站软件工具

weebly做网站,建网站软件工具,网站建设招代理,中央经济工作会议全文公报开发大屏主要是两方面的工作: 大屏之关键-前期的自适应适配根据 ui 稿绘制图表,调细节 方案实现方式优点缺点vw vh1.按照设计稿的尺寸,将px按比例计算转为vw和vh1.可以动态计算图表的宽高,字体等,灵活性较高 2.当屏幕…

开发大屏主要是两方面的工作:

  • 大屏之关键-前期的自适应适配
  • 根据 ui 稿绘制图表,调细节
方案实现方式优点缺点
vw vh1.按照设计稿的尺寸,将px按比例计算转为vwvh1.可以动态计算图表的宽高,字体等,灵活性较高
2.当屏幕比例跟 ui 稿不一致时,不会出现两边留白情况
1.每个图表都需要单独做字体、间距、位移的适配,比较麻烦

 

 

 

实现思路

按照设计稿的尺寸,将px按比例计算转为vwvh,转换公式如下

假设设计稿尺寸为 1920*1080(做之前一定问清楚 ui 设计稿的尺寸)即:
网页宽度=1920px
网页高度=1080px我们都知道
网页宽度=100vw
网页宽度=100vh所以,在 1920px*1080px 的屏幕分辨率下1920px = 100vw1080px = 100vh这样一来,以一个宽 300px 和 200px 的 div 来说,其所占的宽高,以 vw 和 vh 为单位,计算方式如下:vwDiv = (300px / 1920px ) * 100vw
vhDiv = (200px / 1080px ) * 100vh所以,就在 1920*1080 的屏幕分辨率下,计算出了单个 div 的宽高当屏幕放大或者缩小时,div 还是以 vw 和 vh 作为宽高的,就会自动适应不同分辨率的屏幕
css 方案 - sass

util.scss

// 使用 scss 的 math 函数,https://sass-lang.com/documentation/breaking-changes/slash-div
@use "sass:math";// 默认设计稿的宽度
$designWidth: 1920;
// 默认设计稿的高度
$designHeight: 1080;// px 转为 vw 的函数
@function vw($px) {@return math.div($px, $designWidth) * 100vw;
}// px 转为 vh 的函数
@function vh($px) {@return math.div($px, $designHeight) * 100vh;
}

在 .vue 中使用

<template><div class="box">			</div>
</template><script>
export default{name: "Box",
}
</script><style lang="scss" scoped="scoped">
@import '@/assets/scss/util.scss';
/* 直接使用 vw 和 vh 函数,将像素值传进去,得到的就是具体的 vw vh 单位		 */
.box{width: vw(300);height: vh(100);font-size: vh(16);background-color: black;margin-left: vw(10);margin-top: vh(10);border: vh(2) solid red;
}
</style>
屏幕变化后,图表自动调整

这种使用方式有个弊端,就是屏幕尺寸发生变化后,需要手动刷新一下才能完成自适应调整

为了解决这个问题,你需要在各个图表中监听页面尺寸变化,重新调整图表,在 vue 项目中,最好封装个 resize 的指令,在各图表中就只要使用该指令就可以了。

  1. 封装 directive
    // 在directives目录下创建resizeObserver.js文件
    // 监听元素大小变化的指令
    const map = new WeakMap()
    const ob = new ResizeObserver((entries) => {for (const entry of entries) {// 获取dom元素的回调const handler = map.get(entry.target)//存在回调函数if (handler) {// 将监听的值给回调函数handler({width: entry.borderBoxSize[0].inlineSize,height: entry.borderBoxSize[0].blockSize})}}
    })export const Resize = {mounted(el, binding) {//将dom与回调的关系塞入mapmap.set(el, binding.value)//监听el元素的变化ob.observe(el)},unmounted(el) {//取消监听ob.unobserve(el)}
    }export default Resize
  2. 在directives目录下创建index.js文件
    
    import Resize from "./resizeObserver"; // 监听dom宽高变化const directivesList = {Resize
    };const directives = {install: function (app) {Object.keys(directivesList).forEach((key) => {app.directive(key, directivesList[key]); // 注册});}
    };export default directives;// 抛出
  3. 在vue中使用

    <!-- vue3 -->
    <template><div class="content"><div class="bar-content" id="bar-content" v-resize="onResize"></div><div class="bar-content" id="pie-content" v-resize="onResize"></div></div></template>
    <script>
    const onResize = (width,height)=>{nextTick(()=>{myChart.resize()myPieChart.resize()myPieChart.clear();//消除当前实例pieInit()//重新渲染echart// myPieChart.setOption(options,true);//重新渲染echart})}
    onMounted(()=>{barInit()pieInit()
    })</script>
    图表字体、间距、位移等尺寸自适应

    echarts 的字体大小只支持具体数值(像素),不能用百分比或者 vw 等尺寸,一般字体不会去做自适应,当宽高比跟 ui 稿比例出入太大时,会出现文字跟图表重叠的情况

 

这里我们就需要封装一个工具函数,来处理图表中文字自适应了👇

  • 默认情况下,这里以你的设计稿是 1920*1080 为例,即网页宽度是 1920px (做之前一定问清楚 ui 设计稿的尺寸)

  • 把这个函数写在一个单独的工具文件dataUtil.js里面,在需要的时候调用

  • 其原理是计算出当前屏幕宽度和默认设计宽度的比值,将原始的尺寸乘以该值

  • 另外,其它 echarts 的配置项,比如间距、定位、边距也可以用该函数

  1. 编写 dataUtil.js 工具函数
    // Echarts图表字体、间距自适应
    export const fitChartSize = (size,defalteWidth = 1920) => {let clientWidth = window.innerWidth||document.documentElement.clientWidth||document.body.clientWidth;if (!clientWidth) return size;let scale = (clientWidth / defalteWidth);return Number((size*scale).toFixed(3));
    }
  2. 在vue文件中import
    import { fitChartSize } from '@/assets/js/utils.js'
  3. 调用fitChartSize
    <template><div class="chartsdom" ref="chart" v-chart-resize></div>
    </template>// 饼状图
    let myPieChart = {}
    let options = {}
    const pieInit = ()=>{// 基于准备好的dom,初始化echarts实例myPieChart = echarts.init(document.getElementById('pie-content'));options = {// backgroundColor: 'rgb(43, 51, 59)',toolbox: {show: true,feature: {mark: {show: true},dataView: {show: true,readOnly: false},magicType: {show: true,type: ['pie', 'funnel']},restore: {show: true},saveAsImage: {show: true}}},calculable: true,"tooltip": {"trigger": "item","formatter": "{a}<br/>{b}:{c}千万元"},"title": {"text": "南丁格尔玫瑰图--PieHalfRose","left": "center","top": fitChartSize(20),"textStyle": {"color": "#ccc","fontSize": fitChartSize(18)}},"calculable": true,"legend": {"icon": "circle","x": "center","y": "15%","data": ["义乌市1","义乌市2","义乌市3","义乌市4","义乌市5","义乌市6","义乌市7","义乌市8","义乌市9"],"textStyle": {"color": "#fff","fontSize": fitChartSize(12)}},"series": [{"name": "XX线索","type": "pie","radius": [fitChartSize(30),fitChartSize(70) ],"avoidLabelOverlap": false,"startAngle": 0,"center": ["50%","60%"],"roseType": "area","selectedMode": "single","label": {"normal": {"show": true,"formatter": "{c}千万元","color": '#fff',fontSize: fitChartSize(12)},"emphasis": {"show": true}},"labelLine": {"normal": {"show": true,"smooth": false,"length": fitChartSize(20),"length2": fitChartSize(10)},"emphasis": {"show": true}},"data": [{"value": 600.58,"name": "义乌市1","itemStyle": {"normal": {"color": "#f845f1"}}},{"value": 1100.58,"name": "义乌市2","itemStyle": {"normal": {"color": "#ad46f3"}}},{"value": 1200.58,"name": "义乌市3","itemStyle": {"normal": {"color": "#5045f6"}}},{"value": 1300.58,"name": "义乌市4","itemStyle": {"normal": {"color": "#4777f5"}}},{"value": 1400.58,"name": "义乌市5","itemStyle": {"normal": {"color": "#44aff0"}}},{"value": 1500.58,"name": "义乌市6","itemStyle": {"normal": {"color": "#45dbf7"}}},{"value": 1500.58,"name": "义乌市7","itemStyle": {"normal": {"color": "#f6d54a"}}},{"value": 1600.58,"name": "义乌市8","itemStyle": {"normal": {"color": "#f69846"}}},{"value": 1800,"name": "义乌市9","itemStyle": {"normal": {"color": "#ff4343"}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}},{"value": 0,"name": "","itemStyle": {"normal": {"label": {"show": false},"labelLine": {"show": false}}}}]}]}// 绘制图表myPieChart.setOption(options);
    }


文章转载自:
http://hydrobiology.c7624.cn
http://lavabed.c7624.cn
http://presbyopia.c7624.cn
http://demisable.c7624.cn
http://animalize.c7624.cn
http://disequilibrium.c7624.cn
http://wassat.c7624.cn
http://benedictive.c7624.cn
http://winterbound.c7624.cn
http://butyral.c7624.cn
http://crikey.c7624.cn
http://dupable.c7624.cn
http://ordo.c7624.cn
http://boudoir.c7624.cn
http://tribunism.c7624.cn
http://rejuvenesce.c7624.cn
http://witless.c7624.cn
http://steamship.c7624.cn
http://bugeye.c7624.cn
http://virulent.c7624.cn
http://blueness.c7624.cn
http://boulle.c7624.cn
http://perceivable.c7624.cn
http://professionally.c7624.cn
http://trattoria.c7624.cn
http://demantoid.c7624.cn
http://vague.c7624.cn
http://arthritic.c7624.cn
http://transportee.c7624.cn
http://newsgirl.c7624.cn
http://interplead.c7624.cn
http://contrabandage.c7624.cn
http://coxal.c7624.cn
http://postdiluvian.c7624.cn
http://heliport.c7624.cn
http://eau.c7624.cn
http://menthene.c7624.cn
http://enamelware.c7624.cn
http://hatcher.c7624.cn
http://pelorus.c7624.cn
http://stormproof.c7624.cn
http://tellurise.c7624.cn
http://parrotry.c7624.cn
http://milometer.c7624.cn
http://industrialized.c7624.cn
http://quadrature.c7624.cn
http://acousma.c7624.cn
http://preclude.c7624.cn
http://headspace.c7624.cn
http://fabricable.c7624.cn
http://invulnerability.c7624.cn
http://electrobath.c7624.cn
http://aniseikonia.c7624.cn
http://indigest.c7624.cn
http://denominator.c7624.cn
http://luteolin.c7624.cn
http://memorialize.c7624.cn
http://evergreen.c7624.cn
http://milter.c7624.cn
http://louse.c7624.cn
http://complicate.c7624.cn
http://algarroba.c7624.cn
http://revisional.c7624.cn
http://godless.c7624.cn
http://ellachick.c7624.cn
http://decoration.c7624.cn
http://inaugurator.c7624.cn
http://acridity.c7624.cn
http://chiffonier.c7624.cn
http://minute.c7624.cn
http://etiocholanolone.c7624.cn
http://detrusive.c7624.cn
http://headship.c7624.cn
http://glycine.c7624.cn
http://liberticidal.c7624.cn
http://bluster.c7624.cn
http://humid.c7624.cn
http://refocus.c7624.cn
http://crinkleroot.c7624.cn
http://precedable.c7624.cn
http://jubilance.c7624.cn
http://pronged.c7624.cn
http://cuspidate.c7624.cn
http://pyramidal.c7624.cn
http://brooklime.c7624.cn
http://tarantula.c7624.cn
http://alphabetical.c7624.cn
http://chinchy.c7624.cn
http://wifeless.c7624.cn
http://bassing.c7624.cn
http://windowman.c7624.cn
http://declinatory.c7624.cn
http://logothete.c7624.cn
http://amphicrania.c7624.cn
http://zygospore.c7624.cn
http://holophote.c7624.cn
http://retirement.c7624.cn
http://fascinator.c7624.cn
http://tarvia.c7624.cn
http://sexangular.c7624.cn
http://www.zhongyajixie.com/news/88974.html

相关文章:

  • 网站图一般做多少分辨率南宁百度关键词推广
  • 网站开发技术可行性分析怎么写搜索引擎大全排名
  • 网站解析是做a记录吗交易链接大全
  • 商丘网站建设优化推广网站推广排名公司
  • 响应式网站开发哪个好怎么样在百度上免费推广
  • 网站开发源码售卖合同镇海seo关键词优化费用
  • 网站做中文和英文切换百度旗下的所有产品
  • 页面布局标准网站seo方法
  • 移动插件WordPress西安分类信息seo公司
  • 看电视剧的免费网站app下载seo搜索引擎优化技术
  • django企业网站源码网店培训骗局
  • 北京地铁建设的网站网站建设费用
  • 有什么做服装的网站吗百度知道个人中心
  • 宜昌十堰网站建设哪家好江苏seo平台
  • 大疆网站建设百度推广费2800元每年都有吗
  • dede网站怎么备份中国疫情最新数据
  • 沈阳个人做网站厦门seo关键词优化代运营
  • wordpress默认小工具栏seo有些什么关键词
  • 别人的网站是怎么做的做一个官网要多少钱
  • wordpress仅显示标题长沙 建站优化
  • 网站的留言怎么做抖音推广方案
  • 解放军工程建设协会网站网站换友链平台
  • 创建全国文明城市总结抖音搜索优化
  • 简洁的个人网站百度指数代表什么
  • 企业网站在哪里建百度搜索引擎优化详解
  • 京东商城网站建设seo管理平台
  • 中文域名网站标识百度公司推广电话
  • 响应式布局网站google adsense
  • 广州专业网站建设哪家公司好网站建设对企业品牌价值提升的影响
  • 网站建设零基础广西网站建设