1 <html lang="en"> 2 3 <head> 4 <meta charset="UTF-8"> 5 <meta name="viewport" content="width=device-width, initial-scale=1.0"> 6 <meta http-equiv="X-UA-Compatible" content="ie=edge"> 7 <title>过滤器的使用</title> 8 <script src="../js/vue.js"></Script > . 9 </ head > 10 . 11 < body > 12 is < div ID = "App" > 13 is < P > {{MSG | newFormat}} </ P > 14 15 </ div > 16 < Script > . 17 Vue.filter ( ' newFormat ' , function (MSG) { 18 is // Replace addition to the method of the first string can be a regular write . 19 return msg.replace ( / small /G, ' cool ' ) 20 is 21 is }) 22 is var VM = new new Vue ({ 23 is EL: ' #app ' , 24 Data: { 25 MSG: ' I'm a little boy, boy cute small love and affection feeling small people temper ' 26 is } 27 }) 28 </ Script > 29 </ body > 30 31 is </ HTML >