[Solved] TypeError: Cannot read property ‘getAttribute’ of undefined

Today, use ecarts + Vue as the icon and prompt Vue. Runtime. ESM. JS?2b0e: 619 [Vue warn]: error in mounted hook: "typeerror: cannot read property 'getattribute' of undefined"

I found some friends on the Internet and said, “yes, what should be loaded into the mounted this. $nexttick “, but it’s not. I wrote the value of refs wrong

Now let’s start looking for mistakes


    <div class="echart-box"  style="width: 280px;
       height:220px" ref="line_only_dom"></div>


  mounted() {
  methods: {
      drawLine() {
          let self = this;
          let line_dom = this.$refs.line_dom;
          this.mychart = this.$echarts.init(line_dom);



let line_dom = this.$refs.line_dom; change to let line_only_dom = this.$refs.line_only_dom; , this error will be solved

Similar Posts: