Uncaught (in promise) TypeError: Cannot read property 'getAttribute' of null

 

原因:在实例化前打印console.log(document.getElementById('main'))  查看页面是否存在HTML元素

 

解决方案一:延迟加载

  setTimeout(() => {
     this.getChart();
  }, 1000);

 

你可能感兴趣的:(Vue)