Vue filter and vue. js Filter

Source: Internet
Author: User

Vue filter and vue. js Filter

1) Add the pipe character "|", and the filter will take effect.

(The filter capitalize will capital the first letter of the string)

<Div id = "app" >{{ html | capitalize }}</div> <script> var vm = new Vue ({el: "# app", data: {html: "abc", val: "11" }}) </script>

Output Abc

If it is a Chinese character, number, or an uppercase letter, no response is returned.

2) filters cannot be used as expressions. Therefore, they cannot be used in expressions. They can only be used after expressions.

{Html [0] | capitalize} is acceptable. The first letter of html is output and capitalized;

(Html | capitalize) [0]: an error is reported (an error is reported without parentheses). It indicates that the filter cannot be considered as part of the expression.

3) parameters can be added to the filter.

The first parameter is fixed as the expression value (target to be filtered );

The second parameter indicates the first word after the filter;

The third parameter, the second word after the filter, and so on.

 

When a parameter is enclosed in quotation marks, it is regarded as a string. If a parameter is not enclosed in quotation marks, the expression value is passed as a parameter to the filter.

 

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.