<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(88, this); }; }
window.onresize = () => {
// (this.$refs['echart'] as any).$el.resize; (this.$refs['echart'] as any).resize() // console.log(88, this); }; // window.addEventListener("resize", () => { // (this.$refs['echart'] as any).resize() // console.log(88, this);这种绑定方式 拿不到this 所以 使用失败; 记得用 debug 调试! // });
发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/232915.html原文链接:https://javaforall.net
