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.