Vue 3 and Mixin: this.$el.querySelectorAll is not a function

Viewed 1899

When I try this:

createApp(App).mixin({
    methods: {
        myFunction() {
            this.$el.querySelectorAll('input').forEach(...);
        }
    },

    mounted() {
        this.myFunction();
    }
}).mount('#app');

I'm getting a TypeError: this.$el.querySelectorAll is not a function but the weird thing is that everything is working as expected. So this.$el is defined, querySelectorAll() returns the nodes and I can iterate through them with forEach(). What is wrong here, how do I get rid of the error?

0 Answers
Related