Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What is the filter for Vue?

2025-03-12 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly shows you "what is the filter of Vue", the content is easy to understand, clear, hope to help you solve your doubts, let the editor lead you to study and learn "what is the filter of Vue" this article.

1. Filter

Time format related API is used in the case

1.1 understanding of filters

Definition: display after specific formatting of the data to be displayed

Applicable: do some simple logical processing

Features: the filter can do some simple operations without changing the original data and generating new corresponding data.

1. Syntax: data | filter

If no parameter is passed, the data value is passed in by default, and the function is called automatically, and the function can receive the value.

Passing a parameter does not overwrite the first parameter. The first parameter defaults to value, and the second parameter is the passed parameter.

two。 The filter can be in series.

Data | filter | filter

The order of execution is that data is passed as a parameter to the first filter, and the first filter is processed, and the

Value as a parameter to the second filter

1.2 Global filter: Vue.filter (filterName, function (value) {return value.slice (0,4);}) new Vue ({. .. Local filter: new Vue {filters: {filterName (value) {return value.slice (0,4);}

Using filters in html

{{handledata | filtername}} {{handledata | filtername (parameter)} 1.4 filter case methods: {{time ()}} computed: {{time1}} filter: {{number | ftime ("YYYY-MM-DD HH:mm:ss") | qjtime} {{name | qjtime}} Vue.config .productionTip = false / / Global filter Vue.filter ('qjtime' Function (val) {return val.slice (0,4)}) let vm = new Vue ({el:'# root', data: {number: Date.now ()} Methods: {time () {return dayjs (this.number) .format ("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy Computed: {time1: {get () {return dayjs (this.number) .format ("yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy / / Local filter filters: {/ / this is the syntax of ES indicating that if there are passed parameters, the passed parameters will be used. If no parameter is passed, use ftime (val, str = "yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy Name:'I am the second Vue'}}) these are all the contents of the article "what is the filter of Vue?" Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report