-过滤器-自定义全局过滤器
<!DOCTYPE html> < html lang = " en " > < head > < meta charset = " UTF-8 " > < meta name = " viewport " content = " width=device-width, initial-scale=1.0 " > < meta http-equiv = " X-UA-Compatible " content = " ie=edge " > < title > Document </ title > </ head > < body > < div id = " app " > < h1 > {{acount | currency('€')}} </ h1 > </ div > < script src = " ./vue.js " > </ script > < script > // 使用 Vue.filter() 方法自定义全局过滤器 Vue . filter ( 'currency' , function ( value , flag ) { flag = flag || '¥' ; return flag + value . toFixed ( 2 ) ; } ) new Vue ( { el : '#app' , data : { acount : 2000 } } )