TypeError: this.$refs.canvas is undefined
See original GitHub issueExpected Behavior
import the package, extend the Bar Chart and render it.
Actual Behavior
Using this package on a vuetify project, and extending the Bar chart, as the code example of the README, when i want to render the chart, it throws me an error:
[Vue warn]: Error in mounted hook: "TypeError: this.$refs.canvas is undefined"
Environment
- vue.js version: 2.4.2
- vue-chart.js version: 2.7.1
- npm version: 5.5.1
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
vue.js - this.$refs.canvas undefined in vuejs - Stack Overflow
In my project I got undefined with this.$refs.canvas . Also when I use document.getElementById('canvas') , I get null .
Read more >[Solved]-this.$refs.canvas undefined in vuejs-Vue.js
Coding example for the question this.$refs.canvas undefined in vuejs-Vue.js.
Read more >[SOLVED] This.$refs.key returns undefined when it really is
I am using Vue 2.0 with Webpack. When I say console.log(this.$refs) (inside created() method inside a low level component) it retu…
Read more >How to use React createRef - LogRocket Blog
Common errors with React refs. When working with refs in React, you may run into the problem — "TypeError: Cannot read properties of...
Read more >Focus management with Vue refs - Learn web development
This means there's no element to bind the ref to, so it becomes undefined . You might now be thinking "hey, don't we...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Can you post your code?
I would guess you are using single-file-components? If so, you need to remove the
template
part. Vue.js can’t merge templates. So it replaces the template of the extended component. And if you have an empty template tag, it will replace the base components template where the canvas is and some other markup with an empty div.This will not work
This will work
Its added to the readme