zoukankan      html  css  js  c++  java
  • vue28-2.0-过滤器

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
    
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        msg:123
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            {{msg | currency}}    <!--没有效果-->
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
    
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        msg:{a:1,b:2,c:3}
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            {{msg}}    <!--不需要{{msg | json}}:{a:1,b:2,c:3}-->
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            Vue.filter('toDou',function(n){
                //alert(input);
                return n<10?'0'+n:''+n;
            });
    
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        msg:9
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            {{msg | toDou}}  <!--toDou()参数是msg-->
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            Vue.filter('toDou',function(n,a,b){
                alert(a+','+b);
                //alert(input);
                return n<10?'0'+n:''+n;
            });
    
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        msg:9
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            {{msg | toDou '12' '5'}}
        </div>
    </body>
    </html>
    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>智能社——http://www.zhinengshe.com</title>
        <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0">
        <meta name="apple-mobile-web-app-capable" content="yes">
        <meta name="apple-mobile-web-app-status-bar-style" content="black">
        <style>
    
        </style>
        <script src="vue.js"></script>
        <script>
            Vue.filter('toDou',function(n,a,b){
                alert(a+','+b);
                //alert(input);
                return n<10?'0'+n:''+n;
            });
    
            window.onload=function(){
                new Vue({
                    el:'#box',
                    data:{
                        msg:9
                    }
                });
            };
        </script>
    </head>
    <body>
        <div id="box">
            {{msg | toDou('12','5')}}
        </div>
    </body>
    </html>
    6. 过滤器
        之前:
            系统就自带很多过滤
            {{msg | currency}}
            {{msg | json}}
            ....
            limitBy
            filterBy
            .....
        一些简单功能,自己通过js实现
    
        到了2.0, 内置过滤器,全部删除了
    
        lodash    工具库框架,    _.debounce(fn,200)
    
        自定义过滤器——还有
            但是,自定义过滤器传参
    
            之前:    {{msg | toDou '12' '5'}}
            现在:     {{msg | toDou('12','5')}}
  • 相关阅读:
    20150603_Andriod 多个窗体数据回调
    onActivityResult传值的使用
    20150602_Andriod 向窗体传递参数
    20150601_Andriod 打开新窗体
    C# 添加.DLL 出错的解决方法
    c# 中crystal report输出PDF文件
    参考_Android中,如何新建一个界面,并且实现从当前界面切换到到刚才新建的(另外一个)界面
    andriod 新建 Activity_ Form (详细设置)
    sql in
    如何取得GridView被隐藏列的值
  • 原文地址:https://www.cnblogs.com/yaowen/p/6985759.html
Copyright © 2011-2022 走看看