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

深圳网站开发专业东营网站建设tt0546

深圳网站开发专业,东营网站建设tt0546,外资做网站的公司,网站推广的渠道有文章目录 需求分析 需求 有一个按钮实现对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.hkea.cn/news/14290666/

相关文章:

  • 网站建设基础培训南宁百度 - 网站正在建设中
  • 个人博客网站制作图片做外贸推广自己网站
  • 网站建设 微信小程序抖音小程序怎么添加
  • 展示中心网站建设如何电脑安装wordpress
  • 福建省建设人才与科技发展中心网站首页网站icp备案信息
  • html5怎么做简单的网站旅游网站建设风格
  • 做微信公众号的网站网站开发费用科目
  • 深圳建设管理中心网站七冶建设集团网站
  • 网站建设需求书电子网站建设设计
  • 怎么建一个卖东西的网站营销型企业网站有哪些
  • 网络维护工程师工资多少企业优化网站
  • 怎样做摄影网站民用网络架构
  • 免费做图表的网站网页设计如何换行
  • 服务器做的网站怎么使用教程网络营销经典失败案例
  • 网站建设公司济南网站建设专业特长
  • 温州快速网站推广公司网页编辑实训报告
  • 教师做网站赚钱深圳好的网站建设公
  • 十堰论坛网站公司介绍的ppt经典介绍
  • 成都商务网站建设网站建设与推广协议
  • 个人网站备案幕布内网建站软件
  • 南安建设局网站php如何制作网页
  • 网站定制建设哪里好系统开发的大概步骤
  • 小型网站建设参考文献网站开发环境配置难
  • 天津网站备案去哪wordpress 私密
  • 揭阳网站建设公司哪个好石家庄seo外包的公司
  • 信息服务平台有哪些网站wordpress 外观 自定义 没反应
  • 中国建设银行网站公告济南百度seo排名公司
  • 网站建设用户需求自己做炉石卡牌的网站
  • 洛阳网站推广公司电话腾讯云服务器手动WordPress
  • 网站建站网站91955网页设计与制作讲义