美文网首页
vue补零处理 过滤器

vue补零处理 过滤器

作者: 爱代码的派派星 | 来源:发表于2019-11-06 14:42 被阅读0次
 <span>{{data.cost | costText}}</span>

filters: {
    costText: value=>{
      const xsd = value.toString().split(".");
      if (xsd.length == 1) {
        value = value.toString() + ".00";
        return value;
      }
      if (xsd.length > 1) {
        if (xsd[1].length < 2) {
          value = value.toString() + "0";
        }
        return value;
      }
    }
  }

相关文章

网友评论

      本文标题:vue补零处理 过滤器

      本文链接:https://www.haomeiwen.com/subject/zayubctx.html