zoukankan      html  css  js  c++  java
  • VUE学习日记(六) ---- 过滤器 filters、计算属性 computed

    过滤器可在原有值的基础上加一些判定、格式化变量内容

    注意差别,过滤器是 |    计算属性是直接 {{ }} 使用

    <div id="myPage">
          <p>原串:{{message}}</p>
          <p>加过滤器后:{{message|toupper}}</p>

          <p>原值:{{num}}</p>
          <p>经过计算属性后:{{topercentage}}%</p>
        </div>    

        <script>
          var myPage = new Vue({
            el:'#myPage',
            data:{
              message:"这个一个消息输出:",
              num:0.3
            },
            filters:{
              toupper:function(value)
              {
                return value+"Hello Word!";
              }          
            },
            computed:{
              topercentage:function()
              {
                return this.num*100;
              }
            }
          })
        </script>

    效果展示:

  • 相关阅读:
    驱动编程:内存管理基本函数
    POOL_TYPE enumeration
    远程服务器下载jenkins上生成的war包,失败原因
    jenkins ssh 报错
    git分组
    免密登录
    jenkins 生成war包后的下载
    redis 连接失败
    nginx+tomcat+https
    jenkins 拉取 git 代码成功版本
  • 原文地址:https://www.cnblogs.com/JoeYD/p/13552321.html
Copyright © 2011-2022 走看看