VUE do an ajax poll. Where should the polling function be written?

now I have a requirement that I start to make a polling request all the time when I need to enter a page
I want to ask me where this polling request should be written
for example, should my polling function be fn () {}
, should it be written in created {}

?
May.11,2021

write the method normally, and then create a setInterval in create to call this method to save the return value of setInterval. Remember to clean up this timer inside the unmounted lifecycle function, otherwise you will report an error


created() {
  window.InitSetInterval = setInterval(fn(),2000)
},
mounted() {
},
destroyed: {
   clearInterval(window.InitSetInterval )
}


is it better to use settimeout, because you should poll every time you enter this page, and you should only do

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