The scope of JS Code of vue single File component

this is the JS code for Index.vue, but when I router-link to another component, the js code for Index.vue executes again. How to make the JS code of each component only for your own use?

Mar.13,2021

normally the js code of each component is used internally, unless you bind a global event like window.scroll, and do not destroy this event when you leave the route, it will lead to the situation that other pages will still execute.

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-1b3ad54-2b9c1.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-1b3ad54-2b9c1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?