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.