How does Vue write floating ads?

clipboard.png
vue

clipboard.png
htmltemplate

clipboard.png
jsvardatavue$refs

clipboard.png

start it in the updated hook, because other hooks will not catch it (it"s useless to put it in mounted)
but the advertisement doesn"t move. How should I write it?
PS: doesn"t need the code here. It just wants to write a floating ad

.

should be setInterval (this.float (), 10) this is wrong. There is no need for parentheses. Adding parentheses will only be executed once. And your code doesn't have to be written like this, the adFloat method is not necessary, just write it in mounted (). Timers can be defined in data.

data () {
  return {
    timer: null
  }
}
mounted () {
  this.$nextTick(function () {
    const self = this
    this.timer = setInterval(this.float, 10)
    this.$refs[].onmouseover = function () {
        clearInterval(self.timer)
    }
    this.$refs[].onmouseout = function () {
        self.timer = setInterval(self.float, 10)
    }
  })
}

try calling this.adFloat () in the mounted method. https://www.qqwenda.com

Menu