zoukankan      html  css  js  c++  java
  • vue过滤器的使用

    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script>

    </head>
    <body>
    <div id="app">
    <h1>{{666.66222 | toRMB}}</h1>
    <h1>{{888.33388 | toFixed}}</h1>
    <h1>{{money | toFixed | toRMB}}</h1>
    <h1>{{text | readMore(15,'...')}}</h1>
    </div>
    </body>
    </html>
    <script>
    Vue.filter("toRMB",function(value){
    return `¥${value}`;
    })

    new Vue({
    el:"#app",
    data:{
    money:292.59,
    text:"hello world,hello vue"
    },
    filters:{
    toFixed:function(money){
    return money.toFixed(1)
    },
    readMore:function(value,length,suffix){
    console.log(arguments);
    return value.substr(0,length) + suffix
    }
    }
    })
    </script>
  • 相关阅读:
    HTML5拖拽
    HTML5地理定位
    HTML5文件读取
    HTML5全屏
    HTML5网络状态
    可爱的小黄人
    HTML5新增特性
    前端表单标签
    前端(表格)
    前端列表
  • 原文地址:https://www.cnblogs.com/mhtss/p/11335731.html
Copyright © 2011-2022 走看看