In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-02 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >
Share
Shulou(Shulou.com)06/01 Report--
This article mainly introduces vue how to achieve multi-chart resize event decentralization, the article is very detailed, has a certain reference value, interested friends must read it!
Multi-graph resize event decentralization
1.1 General situation
Sometimes we encounter scenarios where there are several diagrams in a component, and we want the diagrams to be resize in the browser resize, so we write in the parent container component:
Mounted () {setTimeout (() = > _ window.onresize = () = > {this.$refs.chart1.chartWrapperDom.resize () this.$refs.chart2.chartWrapperDom.resize () /...}, 200) destroyed () {_ window.onresize = null}
In this way, if the chart component is not on the same page as the parent container component, the state of the child component will be managed by the parent component. For convenience of maintenance, we naturally want the events and state of the child component to be maintained by ourselves. In this way, when adding and deleting components, there is no need to go to the parent components to modify them one by one.
1.2 Optimization
Here the use of lodash throttling throttle function, you can also implement their own, this article also has a throttling implementation to refer to. Take Echarts as an example, in each chart component:
Computed: {/ * Chart DOM * / chartWrapperDom () {const dom = document.getElementById ('consume-analy-chart-wrapper') return dom & & Echarts.init (dom)}, / * * Chart resize throttling, lodash is used here You can also use setTimout to achieve throttling * / chartResize () {return _ .throttle (() = > this.chartWrapperDom & & this.chartWrapperDom.resize (), 400)}, mounted () {window.addEventListener ('resize', this.chartResize)}, destroyed () {window.removeEventListener (' resize', this.chartResize)} these are all the contents of the article "how vue realizes the decentralization of multi-chart resize events". Thank you for reading! Hope to share the content to help you, more related knowledge, welcome to follow the industry information channel!
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 293
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.