Conflicts of vue components

in projects we always define a global variable vm before the script tag in the vue component, then assign a value vm=this in the hook beforeCreate , and then we can use vm anywhere. Like this:

clipboard.png

parammountedvm:

clipboard.png

clipboard.png

test1

clipboard.png

I know that this problem will be solved after using this, and I speculate that it may be the pot of vue-loader, but I also can"t figure out how it works. Please give me your advice!

May.22,2022
The

beforeCreate hook is triggered only as soon as the component is created, and then the component does not trigger without destroying it. So if you write vm in this way, you will only get the context of the component when it was originally created, not the context of the component you are currently using. Put vm = this in the mounted hook to execute.


my understanding is that let vm = null is equivalent to creating a new object globally. After two calls to the test1 component, vm is assigned to the component instance in beforeCreate at the time of the last call, so vm is always the instance of the second test1 component in the mount executed later.

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b34e4b-2b798.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b34e4b-2b798.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?