<div class="echart">
<v-chart :options="polar" ref="echart" /> 1ref获取dom
</div>
.echart{ 2调整容器大小
width: 100%;
.echarts{
width: 100%;
}
}
mounted() {3 用echat的自适应resize方法 在 钩子函数中 覆盖 window的 resize方法
window.onresize = () => {
// (this.$refs['echart'] as any).$el.resize;
(this.$refs['echart'] as any).resize()
// console.log(8888888888888, this);
};
}
之前:有滚动条
之后:自适应
tip:
window.onresize = () => {
// (this.$refs['echart'] as any).$el.resize;
(this.$refs['echart'] as any).resize()
// console.log(8888888888888, this);
};
// window.addEventListener("resize", () => {
// (this.$refs['echart'] as any).resize()
// console.log(8888888888888, this);这种绑定方式 拿不到this 所以 使用失败; 记得用 debug 调试!
// });