Home  >  Article  >  Web Front-end  >  How Vue formats filters

How Vue formats filters

php中世界最好的语言
php中世界最好的语言Original
2018-05-03 15:01:001663browse

这次给大家带来Vue如何将过滤器格式化,Vue将过滤器格式化的注意事项有哪些,下面就是实战案例,一起来看一下。

前端处理一些金额,数字类的数据要求按照固定的格式显示,比如9,527,025,或者带有小数(如1,587.23)仍要三位一断。有些话也不必多说,既然要求如此,实现呗。

作为前端主流框架之一的Vue,类似的功能肯定都有人写的很完善了。我呢,最讨厌不动脑筋去网上找现成的,所以我自己写了一个。话不多说,先放效果图再贴代码(为了展现思路,我面向过程写的,另外这个是针对保留两位小数的数字进行过滤,因为保留整数的太简单了)。



 
  
  
  Vue数字过滤器逢三一断
 
    

   

说明:这个版本是针对保留两位小数的浮点数进行过滤格式化的

       

{{num|NumFormat}}

  

     

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

推荐阅读:

Vue里调用百度地图步骤详解

Angular CLI蓝本生成代码

The above is the detailed content of How Vue formats filters. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn