欢迎来到尧图网

客户服务 关于我们

您的位置:首页 > 房产 > 家装 > vue echarts 柱状图表,点击柱子,路由代参数(X轴坐标)跳转

vue echarts 柱状图表,点击柱子,路由代参数(X轴坐标)跳转

2025/6/8 23:26:11 来源:https://blog.csdn.net/weixin_44229734/article/details/140523787  浏览:    关键词:vue echarts 柱状图表,点击柱子,路由代参数(X轴坐标)跳转

一,echarts 点击事件监控

myChart.on('click', (params) => {if (params.componentType === 'series' && params.dataIndex !== undefined) {const months = this.month_htqd[params.dataIndex]; // 获取点击柱状图的 X 轴坐标值alert(`点击了柱状图,值为: ${months}`);// 根据点击的柱状图数据索引,处理跳转逻辑this.$router.push( {path: `/tzmanager/yueding`,query: {yuedTime: months}});}});

二,跳转到的vue组件,接收参数

data () {return {queryParam: {yuedTime: '' // 初始化为空,接收选择的月份值},},}

三、watch监听router变化,具体参数根据你自己的功能实现去写

 mounted() {if(this.$route.query.yuedTime!=null){const yuedTime =this.$route.query.yuedTime;let dateObj = new Date(yuedTime);this.queryParam.yuedTime =dateObj;this.searchQuery();this.handleUpdateClick();}},watch: {'$route'(to, from) {// 监听路由参数变化if(this.$route.query.yuedTime!=null){const yuedTime =this.$route.query.yuedTime;let dateObj = new Date(yuedTime);this.queryParam.yuedTime = dateObj;// 在这里可以执行刷新组件的其他操作this.searchQuery();}}},

版权声明:

本网仅为发布的内容提供存储空间,不对发表、转载的内容提供任何形式的保证。凡本网注明“来源:XXX网络”的作品,均转载自其它媒体,著作权归作者所有,商业转载请联系作者获得授权,非商业转载请注明出处。

我们尊重并感谢每一位作者,均已注明文章来源和作者。如因作品内容、版权或其它问题,请及时与我们联系,联系邮箱:809451989@qq.com,投稿邮箱:809451989@qq.com

热搜词