分类 代码 下的文章

vue - 滑动页面使el-select的选择项不超出页面而自动隐藏

mounted() {
      console.log('mounted');
      let that = this;
      window.addEventListener('scroll', function (e) {
        that.scrollFunc();
      }, true);
    },
    destroyed() {
      window.removeEventListener('scroll', this.scrollFunc);
    },
    methods: {
      scrollFunc() {
        // let header = document.getElementsByClassName('has-gutter')[0];
        let header = $('.has-gutter');
        let header_offset = header.offset();
        let header_top = +header_offset.top + 50;
        if(this.select === undefined || this.select === null || this.select === ''){
          return false;
        }
        let ref = this.$refs[this.select.id][0] || null;
        $('.el-select-dropdown').each(function (e) {
          if($(this).css('display') === 'none'){
          }else{
            let el_select_dropdown = this;
            let el_select_dropdown_offset_top = el_select_dropdown.offsetTop;
            if(+el_select_dropdown_offset_top <= +header_top){
              console.log('小于了');
              ref && ref.blur();
              // $(this).css('display', 'none');
              // ref.$refs.input.blur();
            }
          }
        });
      },
}

阅读全文

vue - 获取元素相对页面的高度

let keyboardDiv = document.getElementsByClassName('keyboard-container')[0];
let keyboard_offsetTop = keyboardDiv.offsetTop;
console.log('键盘高度:' + keyboard_offsetTop);
let wHeight = +keyboard_offsetTop + 270;
let signId = item.signId;
let inputId = 'input-' + signId;
let inputDiv = document.getElementById(inputId);
let ref = this.$refs[inputId][0];
let input_top = ref.$el.getBoundingClientRect().top;

CSS - 一个 a:hover

#test a:hover {
  text-decoration: none;
  background: url("http://xiaowiba.com/demo/svg/test-ahover.svg")
    repeat-x 0 100% !important;
  background-size: 20px auto !important;
  animation: waveMove 1s infinite linear !important;
}

阅读全文

css - 斜线

#lineTd {
            width: 200px;
            color: #000000;
            font-size: 30px;
            text-align: center;
            font-weight: 100;
            border-bottom: 1px solid #6BA1FF;
            height: 130px;
            box-sizing: border-box;
            text-indent: 0;
            background: linear-gradient(33deg, transparent 49.5%, #CDD4F3 49.5%, #CDD4F3 50.5%, transparent 50.5%);
          }

效果

阅读全文

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 ':'',
              ]"