[Vuejs]-VueJS references in a component don't work

0๐Ÿ‘

โœ…

As @skirtle says, you cannot have a render function and a template. In fact I found that with an empty render function, Vue replaces the element with an empty comment.

I also found that capital letters in the component name caused issues.

The solution for me was to replace my render function as a method like this:

methods: {
    setValue: function(value) {
        this.value = value;
        // TODO: Draw on canvas here.
    }
},

I also added a ref to the entry in the template and when the value updated used the ref to get the component and used my new setValue method to both set the internal value and redraw the canvas to represent that value.

Leave a comment