vue on the primary filters using filter

Filter data for rendering, such as (after the decimal point will vue 0 of all data types into an integer) fractional retained, such as the character data before joining the monetary

Filter is divided into global and local, local stresses where

filters and methods, computed at the same level, and the filter type is generally a function of the type

Syntax: <h1> {{original data | filter name}} </ h1> // "|" means delimiter

Typically used mustache or syntax: bind directive

Case: After traversing two data retention and added $ symbol before the data

data:

      bookPrice: [1, 2, 2, 3, 5, 9]

 

web:

 <h1 v-for='item in bookPrice'>{{item | getPrices }}</h1>
        <-! Item: the original data, getNumbers filter name, used between the two "|" separates ->

 

filters:

 getPrices(item) {
                    return '$' + item.toFixed(2)
                }

 

This completes the second rendering data.

the above.

Guess you like

Origin www.cnblogs.com/hjk1124/p/12273528.html