P
P
partyzanx2021-01-11 03:18:32
Vue.js
partyzanx, 2021-01-11 03:18:32

How to make a component reload triggered by any click anywhere on the site?

I need to reload the ad component no more than once every 30 seconds, and so that the reload will work when clicking anywhere on the site. For example, the user replied to a comment or clicked a like, and if the date recorded in the global variable is more than 30 seconds than the current date, then the reload of the ad component is triggered.
The question is exactly how to track any click anywhere on the site and reload the component?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Dmitry Barkowski, 2021-01-11
@partyzanx

Set the key to the desired component (componentKey = 1) using the :key directive. When clicking on the document, update the component by increasing the value of the key by one (componentKey++). Write down the time of the last click and then build the logic of the next click based on the time of the last click on the document.

A
Alexey, 2021-01-11
@AlexeyCaTHaR

Force re-render = https://michaelnthiessen.com/force-re-render/
And click = native js event.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question