M
M
mmmq2020-08-30 19:58:52
JavaScript
mmmq, 2020-08-30 19:58:52

How to correctly use this in mixins when working with a class?

I understand how vuejs works, I try to combine the class and mixins. I want to understand how to use the common dataand func- functions. When calling the function, it throws an error:

Uncaught TypeError: Cannot read property 'test1' of undefined"


I understand that he does not find 'test1',it; the function is a nested object, so there is no access to the parent this. How to fix it?

https://jsfiddle.net/xuqm083b/

Answer the question

In order to leave comments, you need to log in

1 answer(s)
0
0xD34F, 2020-08-30
@mmmq

Bind the context in advance ( bind ), or specify it when calling ( call , apply ).

Understanding how vuejs works

vue bind context ahead of time

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question