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

手机网站建设实验报告功能网站开发

手机网站建设实验报告,功能网站开发,wordpress插件安装教程视频,怎么建设外贸网站文章目录 需求分析 需求 有一个按钮实现对Echarts的指定缩放与拉长#xff0c;形成自适应效果 拉长后效果图 该块元素缩短后效果图 分析 因为我习惯使用 ref 来获取组件的 DOM 元素#xff0c;然后进行挂载 div refechartsRef idmyDiv :sty… 文章目录 需求分析 需求 有一个按钮实现对Echarts的指定缩放与拉长形成自适应效果 拉长后效果图 该块元素缩短后效果图 分析 因为我习惯使用 ref 来获取组件的 DOM 元素然后进行挂载 div refechartsRef idmyDiv :style{ width, height }/divechartInstance echarts.init(echartsRef.value, macarons);小插入————踩坑【别试】 想的是通过document.querySelector 修改宽高但是并未监听到 ref 的宽高被修改【未成功】 网上有说是要销毁 DOM 重新进行绘制【未成功】 watch(flagFold, (newVal) {echartResizes(echartInstance)const myDiv document.querySelector(#myDiv )myDiv.style.width newVal ? 1400px : 600pxif (echartInstance) {echartInstance.resize();} })因此采用如下解决办法 因此在监听变化的时候要修改 ref 获取到的元素的宽度和高度 templatediv!-- 使用 ref 来获取组件的 DOM 元素 --div refechartsContainer :style{ width: containerWidth px, height: containerHeight px }/div/div /templatescript import { ref, onMounted, watch } from vue; import echarts from echarts;export default {setup() {// 使用 ref 来创建响应式对象const echartsContainer ref(null);const containerWidth ref(0);const containerHeight ref(0);let echartsInstance;onMounted(() {// 初始化 ECharts 实例echartsInstance echarts.init(echartsContainer.value);// 在组件挂载后调整组件宽度和高度adjustSize();});// 监听组件宽度和高度变化watch([() echartsContainer.value.offsetWidth, () echartsContainer.value.offsetHeight], ([newWidth, newHeight], [oldWidth, oldHeight]) {// 当组件宽度或高度发生变化时调用 adjustSize 方法adjustSize();});const adjustSize () {// 获取组件宽度和高度containerWidth.value echartsContainer.value.offsetWidth;containerHeight.value echartsContainer.value.offsetHeight;// 修改组件宽度和高度echartsInstance.resize({width: containerWidth.value,height: containerHeight.value});};return {echartsContainer,containerWidth,containerHeight};} } /script源码展示 templatediv refechartsRef idmyDiv :style{ width, height }/div /templatescript langts setup import {ref,reactive,watch,toRefs,onMounted,onBeforeUnmount,computed,watchEffect } from vue; import * as echarts from echarts; import { echartResize, echartResizes } from /utils/echsrts; import { useToolStore } from /store;const ToolStore useToolStore()const flagFold computed(() {return ToolStore.isFold }) watch(flagFold, (newVal) {echartResizes(echartInstance)// const myDiv document.querySelector(#myDiv )// myDiv.style.width newVal ? 1400px : 600pxechartInstance.resize({width: newVal ? 1400 : 600,});if (echartInstance) {echartInstance.resize();} })/*** description : 安全监测模块* author : Hukang* param : * date : 2024-03-05 14:59:56 */ const props defineProps({//子组件接收父组件传递过来的值chartData: Object,width: {type: String,default: 600px,required: false // 是否必传},height: {type: String,default: 580px,required: false // 是否必传} }) //使用父组件传递过来的值 const { chartData } toRefs(props)const option ref({title: {text: },tooltip: {trigger: axis,axisPointer: {type: cross,label: {backgroundColor: #6a7985}}},legend: {data: [],right: 5%,top: 0,textStyle: {fontSize: 12, //字体大小color: #000 //字体颜色}},toolbox: {feature: {saveAsImage: {show: true,title: 点击保存}},right: 10%, // 从右边缘的距离top: 10%},grid: {left: 3%,right: 8%,bottom: 8%,top: 15%,containLabel: true},xAxis: {type: category,boundaryGap: false,data: [],axisLine: {lineStyle: {color: #000}},axisTick: {show: true//刻度线},nameTextStyle: {color: #000,fontSize: 12},axisLabel: {color: #000,fontSize: 12,formatter: (value, index) {return value.replace(/(\d{4})-(\d{1,2})-(\d{1,2}).*/, $1-$2-$3).slice(5);}}},yAxis: [{name: ,type: value,axisTick: {show: true},nameTextStyle: {color: #000,fontSize: 12},axisLine: {show: true,lineStyle: {color: #000}},splitLine: {lineStyle: {type: dashed, //虚线color: rgba(0,0,0,0.8)},show: true //隐藏},min(v) {return v.min}}],dataZoom: [{show: true,type: slider,handleSize: 32, // 两边的按钮大小},{type: inside}],series: [], })const echartsRef refstring(); let echartInstance; watch(chartData, (newVal) {if (newVal) {option.value newValechartInstance.setOption(option.value);window.addEventListener(resize, () {if (echartInstance) {echartInstance.resize();}})} }, { deep: true })onMounted(() {echartInstance echarts.init(echartsRef.value, macarons);}) onBeforeUnmount(() {if (echartInstance echartInstance.dispose) {echartInstance null;} }) /scriptstyle scoped langless/style
http://www.dnsts.com.cn/news/58668.html

相关文章:

  • 高速公路建设网站人才网最新招聘信息网
  • 网站建设报告 商业价值做网络传销网站犯罪吗
  • 电子商务网站开发课题简介鹿泉区住房建设局网站
  • 网站里面的视频功能怎么做自己建网站的费用
  • 高价词网站源码wordpress更改链接地址
  • 织梦如何仿手机网站做网站简单么
  • 家装企业网站系统下载2345网址导航下载官网
  • 嵌入式网站开发学习平邑哪里有做网站的
  • 自己电脑做网站服务器小工具网站建设报价套餐
  • 牡丹江建站网盟官方网站
  • 沙坪建设集团网站互联网营销 网站 推荐
  • 商城网站包括哪些模块xml网站地图制作
  • 个人网站上线流程wordpress建一个网站
  • 网站建设中怎么编辑图片西安 美院 网站建设
  • 国外电商网站如何建立自适应网页设计尺寸
  • 广西城乡住房建设厅网站手机logo制作软件
  • 绑定手机网站文件夹湖北专升本网站建设
  • 安徽六安金寨县网站谷歌seo做哪些
  • 免费做店招哪个网站好做网站公司会场主持台词
  • 晋城网站seo站长工具高清
  • 网站开发要学什么网站升级对外解决方案
  • 网站网页制作企建设部注册中心网站
  • 宁波网站建设选择荣胜网络站长平台社区
  • 网站开发进度设计山东城建设计院网站
  • 做网站的就业前景建筑工程找工作哪个网站好
  • 深南花园裙楼+网站建设商务网站建设课程设计
  • ps怎样做网站详情页asp无刷新网站模板
  • 营销型网站建设_做网站seo排行榜
  • 营业推广的概念seo关键词排名怎么提升
  • 专业网站建设大型公司新网站如何做友情链接