<!DOCTYPE html>
<html>

<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>
</head>

<body>
    <div id='app'>

        <p>处理前</p>
        {{msg}}
        <p>处理后</p>
        {{msg | toUpper}}
    </div>
    <script src='./vue.js'></script>
    <script>
        new Vue({
            el: '#app',
            data: {
                msg: "abc"
            },
            // 过滤器
            // 1. 定义 通过选项filters
            // 2. 功能
            // 3. 使用
            filters: {
                // 过滤器名字 : 函数(v)
                // toUpper: function(v) {
                //     return 结果;
                // },
                toUpper(v) {
                    return v.charAt(0).toUpperCase() + v.substr(1);
                }
            },
            methods: {

            }
        });
    </script>
</body>

</html>


15-基础-过滤器-局部过滤器

相关文章:

  • 2022-12-23
  • 2021-06-06
  • 2021-12-13
  • 2022-02-10
  • 2022-02-08
  • 2022-12-23
  • 2022-03-04
猜你喜欢
  • 2022-12-23
  • 2021-11-05
  • 2022-12-23
  • 2021-08-28
  • 2021-04-12
  • 2021-11-13
  • 2022-12-23
相关资源
相似解决方案