• vue 常用设置


    vue 常用 计算,方法,监听,过滤格式

     1 var app =new Vue({
     2     el:"#app",
     3     data:{
     4         fileNames:''
     5     },
     6     computed:{//计算属性
     7         tbinfo:function(){            
     8             return 1+1;
     9         }
    10     },
    11     methods:{
    12         changeFeedType:function (type){//切换反馈类型
    13             this.feedType=type;
    14             this.$nextTick(function () { //视图更新后执行方法
    15                 computerHeight();//设置高度
    16             });            
    17         },
    18         removeFile:function(index){//清空文件
    19             var file = document.getElementById("fileUP");
    20              // for IE, Opera, Safari, Chrome
    21              if (file.outerHTML) {
    22                  file.outerHTML = file.outerHTML;
    23              } else { // FF(包括3.5)
    24                  file.value = "";
    25              };             
    26              this.filesArr.splice(index,1);
    27 
    28         }    
    29     },
    30     watch: {//监听 data变化
    31         fileNames: function (val) {
    32             this.$nextTick(function () {
    33                 //computerHeight();//设置高度
    34             });
    35         }   
    36         
    37       },
    38     filters:{//过滤
    39           toFix:function(v){              
    40               v=v/1024/1024;//换算为M
    41               if(v<0.01){
    42                   v=v*1024;
    43                   v=v.toFixed(2)+'KB';
    44                   return v;
    45               }else if(v>1024){
    46                   v=v/1024; //gB
    47                   return v.toFixed(2)+'GB'
    48               };
    49               return v.toFixed(2)+'MB'
    50           }
    51       }
    52      
    53 });

     数据更新后,等待视图更新后执行的方法

     Vue.nextTick(function () {
                                           console.log('数据视图更新后执行')
                        computerHeight();//设置高度                    
                    });    
  • 相关阅读:
    LoadLibrary And GetProcAddress And FreeLibrary
    Preprocessor Directives
    Pragma Directives
    How to use Union in c++?
    WhiteSpace
    Export Class and Struct
    Two Ways To Export from a DLL
    Know more about the organization of solution and project
    Cygwin
    二叉树及其应用
  • 原文地址:https://www.cnblogs.com/s-xl/p/10692370.html
Copyright © 2020-2023  润新知