I don’t know how popular VUe3 is, I need to use VUE to write a small project recently, so I want to use VUe3 to write it. By the way, I learn and make progress. Everything is going well, the new features in VUe3 are very simple, and I learned them in a short time.

1. First, cancel this in the setup entry function.

This news added a lot of confusion for me who was still thinking about VUe2, because there are a lot of third party dependencies and vue’s own ecological object depends on this. With such confusion, I finally encountered a problem, when I wanted to get the ref object bound in the template, I was frozen!! Yes, I panicked, without this, how do I get??

2. Solution =======

After a series of search engine groping and thinking like a ball of wool, I found a very good solution, inspired by other posts. First, let’s take a look at the common solution of the network: getCurrentInstance(); The documentation on the official website makes it clear that this function should be used sparingly and that it does not work in packaged files.

How to get this.$refs gracefully and correctly?

In three steps!

1. Bind ref

Import the ref function

Rely on reactive binding of the REF element

I haven’t had time to go into the specifics of this method, but for now, it’s a neat way to use refDom, and with responsive registration, mom doesn’t have to worry about my template loading anymore

The next step, of course, is use

We can use the ref binding template object in setup from the states object. We can use the ref binding template object from the States object.