| | |
| | | <!-- 仪表盘组件 |
| | | 父组件传入数据源与data绑定后 自动渲染 |
| | | 父组件最好启动异步组件 |
| | | 响应式变化大小 |
| | | --> |
| | | <template> |
| | | <div class="dashboard-item" ref="chartContainer"></div> |
| | |
| | | mounted() { |
| | | // 页面加载完成后调用仪表盘 |
| | | this.init() |
| | | window.addEventListener('resize',this.updateChart) |
| | | }, |
| | | methods:{ |
| | | // 初始化仪表盘 |
| | |
| | | } |
| | | ] |
| | | }); |
| | | }, |
| | | updateChart(){ |
| | | this.$nextTick(() => { |
| | | if (this.chart) { |
| | | this.chart.resize(); |
| | | } |
| | | }); |
| | | } |
| | | }, |
| | | beforeUnmount() { |
| | | // 销毁仪表盘实例 |
| | | this.chart.dispose(); |
| | | } |
| | | }, |
| | | |
| | | }; |
| | | </script> |
| | | |
| | | <style> |
| | | .dashboard-item { |
| | | width: 400px; |
| | | width:100%; |
| | | height: 300px; |
| | | margin: 10px; |
| | | /* margin: 10px; */ |
| | | } |
| | | </style> |