• 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')}}
  • 相关阅读:
    CSS布局 ——从display,position, float属性谈起
    svchost.exe启动服务原理(如何查看系统服务究竟启动了哪个文件)
    简单模拟多线程Socket通信(java)
    把爱融入程序——程序,源自生活,高于生活
    SQL LIKE语句多条件贪婪匹配算法
    SQL多条件模糊查询解决方案(类似百度搜索)
    SQL LIKE语句多条件贪婪加权匹配算法(改进版)
    Foxmail添加微软最新outlook.com邮箱解决方案
    SQL LIKE语句多条件贪婪加权匹配(新增必要词指定)
    搜索的艺术——搜索引擎使用心得
  • 原文地址:https://www.cnblogs.com/yaowen/p/6985759.html
Copyright © 2020-2023  润新知