最近项目中用到的方法

1.获取小数点后的字符串(情景时需要获取文件类型 你好.png/新生手册.doc)

var filename = '新生.doc'
filename.substring(filename.lastIndexOf('.') + 1)
或者
filename.split('.')[1]

2.判断IOS还是Android

appSource () {
      const u = navigator.userAgent
      const isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/)
      const isAndroid = u.indexOf('Android') > -1 || u.indexOf('Linux') > -1
      if (isiOS) {
        // ios
        this.isAndroidType = false
      } else if (isAndroid) {
        // andriod
        this.isAndroidType = true
      }
    },

3.删除某个数组中指定的对象(filter,实现去掉name是小王的对象)

var arr = [{name:'小李',age:'17'},{name:'小王',age:'17'},{name:'小陈',age:'18'}]
    arr = arr.filter(function(item){
        console.log(item)
        return item.name != '小王'
    })

 

 4.获取接口的文档,立马给每个对象添加checked字段来实现是否选择的判断

for (let i = 0; i < this.fileList.length; i++) {
   //fileList是获取的数组对象,给每个对象添加checked,值为false
    this.$set(this.fileList[i], 'checked', false)
}

5.H5中移动端禁止长按复制文本功能,很多手机都有这种功能,会造成用户体验不好,所以干脆全部禁止.在App.vue里面添加,input和textarea一定要记着加,不然这两个标签到时候输入不了

*{
  -webkit-touch-callout:none;  /*系统默认菜单被禁用*/
  -webkit-user-select:none; /*webkit浏览器*/
  -khtml-user-select:none; /*早期浏览器*/
  -moz-user-select:none; /*火狐*/
  -ms-user-select:none;  /*IE10*/
  user-select:none;
}
input,textarea {
  -webkit-user-select: auto !important;
}

 

 

 

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值