Use of Vue2.0 series filters and vue2.0 series Filters

Source: Internet
Author: User

Use of Vue2.0 series filters and vue2.0 series Filters

Vue2.0 has deprecated the filter and requires a custom filter for common text formatting.

It feels super easy to use !!

The filter can be used in two places: Double curly brackets interpolation and v-bind expressions.

The filter should be added at the end of the JavaScript expression, indicated by the pipeline operator.

1. Register a global Filter

Note:
1. The global method Vue. filter () registers a custom filter, which must be placed before vue instantiation.
2. The filter function always uses the expression value as the first parameter. Parameters with quotation marks are considered as strings, and parameters without quotation marks are calculated by expressions.
3. You can set two filter parameters so that the two filters do not conflict with each other.
4. Data input from input can be processed before it is passed to the model.

Case

<! DOCTYPE html> 

Case effect:

2. Register within the instantiation

The filter can also be registered within the instance and only registered in the instance that uses it.

Adapted from the above case:

<! DOCTYPE html> 

Effect:

Iii. Common Filters

Converts a timestamp to the time format mm-dd hh: tt.

<! DOCTYPE html> 

Case effect:

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.