Vue2.0 filters过滤器使用方法

Vue2.0 filters过滤器使用方法

创建filters

    filters:{
        DateTime(val){
        // 这里的val是传入的值
        return SOtime.time6(val);
        //  return 是返回的值
        }
    },

使用方法

  1. 双花括号插值

    {{message | myFilter}}
  2. v-bind表达式

    <el-tag :type="message | myFilter"></el-tag>
  3. vue的生命周期中,如用在methods方法中

    this.$options.filters['这里是过滤器的名字']('过滤器的参数')
  4. 还可以接受函数作为参数

    this.$options.filters['这里是过滤器的名字']('参数一', this.fun('zhangyue'))
  5. 过滤器可以串联,filterA的结果将被传入filterB的参数中

    {{message | filterA | filterB}}
©版权声明
THE END
喜欢就支持一下吧
点赞0 分享
评论 抢沙发

请登录后发表评论

    暂无评论内容