Vue implements built-in filter instances and vue filter instances

Source: Internet
Author: User

Vue implements built-in filter instances and vue filter instances

Filter Writing Method

{{ message | Filter}}

Two Vue built-in filter: capitalize

Function: uppercase letters

<! DOCTYPE html> 

Above code output: Abc

Third Vue's built-in filter: uppercase

Function: all uppercase

<! DOCTYPE html> 

Above code output: ABC

Four Vue built-in filter: uppercase

Function: All lowercase letters

<! DOCTYPE html> 

Above code output: abc

Vue's built-in filter: currency

Function: outputs money and decimal points

Parameters:

The first parameter {String} [currency symbol]-default value: '$'

The second parameter {Number} [decimal place]-default value: 2

<! DOCTYPE html> 

Six Vue built-in filter: pluralize

Function: if there is only one parameter, simply add "s" at the end of the complex form ". If there are multiple parameters, the parameter is treated as a string array, corresponding to one, two, three... The plural word. If the number of values is greater than the number of parameters, the last parameter is used.

Parameter: {String} single, [double, triple ,...

<! DOCTYPE html> 

7. Vue built-in filter: debounce

(1) Restrictions: must be used in @

(2) parameter: {Number} [wait]-default value: 300

(3) function: Package the processor to delay the execution of x ms, default delay of 300 ms. The encapsulated processor will at least delay x ms after calling, if called again before the delay ends, the delay duration is reset to x ms.

<! DOCTYPE html> 

8. Vue built-in filter: limitBy

(1) restriction: It must be used in v-for (array ).

(2) Two parameters:

First parameter: Number obtained by {Number}

Second parameter: {Number} offset

<! DOCTYPE html> 

9. Vue built-in filter: filterBy

(1) restriction: It must be used in v-for (array ).

(2) three parameters:

First parameter: {String | Function} String to be searched

Second parameter: in (optional, specifying the search location)

Third parameter: {String} (optional, array format)

<! DOCTYPE html> 

10. Vue built-in filter: orderBy

(1) restriction: It must be used in v-for (array ).

(2) three parameters:

First parameter: {String | Array <String> | Function} String to be searched

The second parameter: {String} the optional parameter order determines whether the result is in ascending order (order> = 0) or in descending order (order <0). The default value is in ascending order.

<! DOCTYPE html> 

Source Code address: vue-filter_jb51.rar

The above is all the content of this article. I hope it will be helpful for your learning and support for helping customers.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.