vue使用记录

1、vue 基于vue-seamless-scroll无缝滚动:https://www.jianshu.com/p/a2a7d3a9cf2b
2、定时器:setInterval(一直执行) setTimeout(只执行一次)

setInterval(this.testOffline, 500)
setTimeout(this.testOffline, 500)

3、Class 与 Style 绑定

<div
  class="static"
  v-bind:class="{ active: isActive, 'text-danger': hasError }"
></div>

4、前端数据操作使用,使用介绍:https://www.npmjs.com/package/decimal.js

decimal.js

5、setTimeout出现is not a function

// 此方式会出现is not a function
setTimeout(function () {
   this.setData({
      index: "1"
   })
}, 3000)

// 使用that代替this
var that = this;
setTimeout(function () {
   that.setData({
      index: "1"
   })
}, 3000)

//例如:
      const that = this
      setTimeout(function () {
        that.$set(that.isWarn, cameraRank, false)
      }, 5000)

// 在es6中 , 使用箭头函数是不存在这个问题的
setTimeout( () => {
            console.log(this.type + ' says ' + say)
        }, 1000)

https://www.cnblogs.com/fozero/p/7841488.html
当我们使用箭头函数时,函数体内的this对象,就是定义时所在的对象,而不是使用时所在的对象。
并不是因为箭头函数内部有绑定this的机制,实际原因是箭头函数根本没有自己的this,它的this是继承外面的,因此内部的this就是外层代码块的this。

原文地址:https://www.cnblogs.com/InternetJava/p/15731278.html