Local filter:
< HTML > < head > < title > VUE </ title > < Meta charset = "UTF-. 8" > </ head > < body > < div ID = "App" > {{MSG | toFixed (. 1)}} < ! - msg is the value of input parameters, method parameters are parameters in the input as a -> </ div > </ body > < Script src = "node_modules \ VUE \ dist \ vue.js" > </script> <script> VM the let = new new Vue ({ EL: " #app " , Filters: { // toFixed (INPUT, the param1, param2, Param3) toFixed (INPUT, NUM) { // The second parameter is the number of decimal return ' ¥ ' + input.toFixed (NUM); } }, Data: { MSG: 15.123 } }); </ Script > </ HTML >
Global filter (placed prior to remember all instances)
< HTML > < head > < title > VUE </ title > < Meta charset = "UTF-. 8" > </ head > < body > < div ID = "App" > {{MSG | My (2)}} < ! - msg is the value of input parameters, method parameters are parameters in the input as a -> </ div > </ body > < Script src = "node_modules \ VUE \ dist \ vue.js" > </ Script > <script> // global filter // Vue.filter (name, function) Vue.filter ( ' My ' , (INPUT, NUM) => { return ' ¥ ' + input.toFixed (NUM); }) // local filtered let vm = new new Vue ({ EL: " #app " , Filters: { // toFixed (INPUT, the param1, param2, Param3) toFixed (INPUT, NUM) { // The second parameter is the number of decimal return ' ¥ ' + INPUT .toFixed (NUM); } }, data:{ msg:15.123 } }); </script> </html>
// ps: Filters are often used to take good grasp