vue - 长摁操作

let timeOutEvent=0;//定时器  
// html
<div @touchstart="gotouchstart" @touchmove="gotouchmove" @touchend="gotouchend"></div>
//js
gotouchstart(){
   let that = this;
   clearTimeout(timeOutEvent);//清除定时器
   timeOutEvent = 0;
   timeOutEvent = setTimeout(function(){
        //执行长按要执行的内容,
        // TODO
     },600);//这里设置定时
 },
//手释放,如果在500毫秒内就释放,则取消长按事件,此时可以执行onclick应该执行的事件
gotouchend(){
    clearTimeout(timeOutEvent);
      if(timeOutEvent!=0){
        //这里写要执行的内容(尤如onclick事件)
     }
},
//如果手指有移动,则取消所有事件,此时说明用户只是要移动而不是长按 
gotouchmove(){
     clearTimeout(timeOutEvent);//清除定时器
     timeOutEvent = 0;
},

vue - 动态绑定 class

:class="[
              ' dialog-bedOrRoomList text-ellipsis ',
              isSelect === true?' active ':' ',
              isDisabled === true?' disabled ':'',
              ]"

layui弹层之如何在layer.prompt输入值为空的情况下点击确定继续执行逻辑

layer.prompt({
    formType: 2,
    title: '请填写排除原因(注:必填项)',
    area: ['500px', '150px'],
    btnAlign: 'c',
    yes: function(index, layero){
        // 获取文本框输入的值
        var value = layero.find(".layui-layer-input").val();
        if (value) {
            alert("输入值为:" + value);
            layer.close(index);
        } else {
            alert("输入值为空!");
        }
    }
});

jQuery - 获取对象 object 的长度

var bookAuthors = {
    "Farmer Giles of Ham": "J.R.R. Tolkien",
    "Out of the Silent Planet": "C.S. Lewis",
    "The Place of the Lion": "Charles Williams",
    "Poetic Diction": "Owen Barfield"
};
// 获取对象的key值
var arr = Object.keys(bookAuthors);
console.log(arr);
// 获取长度
console.log(arr.length);

vue 中 filters 获取 data 里的数据

// 声明一个全局变量
let that;
// 在生命周期 beforeCreate里面改变this指向
beforeCreate: function () {
     that = this;
},
filters:{
  timeFilter(val){
      let data = that.time;
      return data;
  }
},