关于前端平时需要用到的方法(未完成)

一、this.$forceUpdate();强制刷新

 

 

二,数据重置刷新赋值

 this.dataals = Object.assign({}, this.dataals)
 
 

2、向下取整的函数
Math.floor();
例如:Math.floor( 23.2222222); // 23

3、向上取整
Math.ceil();
例如: Math.ceil(23.333333); // 24

4、四舍五入
Math.round();
例如:Math.round(23.33333); // 23

5、四舍五入取n位小数,运算后得到的是字符串
().toFixed(n); // 取小数点后n位
例如:(36.36498524).toFixed(3); // 36.365

 

 

 

 

 

 

 

 

  <div class="views" @mouseleave="mouselev" :style="{backgroundImage:'url('+styles+')'}">
 
  styles:require('../../../../../../assets/image/icon__biaozhun.png')
 
 if(this.dataitemall.subjectDomainType=='标签'){
        this.styles=require('../../../../../../assets/image/icon__biaoqian.png')
        }else if(this.dataitemall.subjectDomainType=='分析侧资产'){
        this.styles=require('../../../../../../assets/image/icon__fenxi.png')
        }else if(this.dataitemall.subjectDomainType=='交易侧资产'){
        this.styles=require('../../../../../../assets/image/icon__jiaoyi.png')
        }else if(this.dataitemall.subjectDomainType=='数据标准'){
        this.styles=require('../../../../../../assets/image/icon__biaozhun.png')
        }else if(this.dataitemall.subjectDomainType=='数据质量规则'){
        this.styles=require('../../../../../../assets/image/icon__guize.png')
        }
 
 

/*滚动条样式*/
        .main::-webkit-scrollbar {
            width: 4px;    
            /*height: 4px;*/
        }
       .main::-webkit-scrollbar-thumb {
           border-radius:10px;
           -webkit-box-shadow:inset 0 0 5px #bfbfbf;
           background:#bfbfbf;
         }
   .main::-webkit-scrollbar-track {
            -webkit-box-shadow: inset 0 0 5px #FAFAFA;
            border-radius: 0;
            background: #FAFAFA;
         }
 
 
 
//监听浏览器窗口大小改变
  mounted(){
    this.$nextTick(()=>{
      this.heights= document.documentElement.clientHeight - 400
              window.addEventListener('resize', () => { 
                       //浏览器变化执行动作
                       this.heights= document.documentElement.clientHeight - 400
              });
          })
},
 
 
 
 
 
//获取浏览器版本
 this.$nextTick(()=>{
      if(navigator.userAgent.toLowerCase().match(/chrome\/([\d.]+)/)[1].substring(0,navigator.userAgent.toLowerCase().match(/chrome\/([\d.]+)/)[1].indexOf('.'))>=89)
       {
         this.heights=0
       }else{
        this.heights=1
      }
      }) 
////////////////基于谷歌版本89版本以上的兼容问题过于垃圾,十分吐槽,但我却毫无办法!!!!
 
 
 
 
 
 

Vue中解决多个组件引用了同一个对象作为数据时,当一个组件改动了数据对象时,其他对象的数据也会随着同步改动的情况

 

 this.dataallsCon=JSON.parse(JSON.stringify(this.dataalls));
 
 
 
 
posted @ 2021-03-02 11:25  黄梓  阅读(56)  评论(0编辑  收藏  举报