vue base ---- filters filter

1. The scene: a feature can be used in each component, and computed although the cache, but can not be used in every component, if required, each one needs to write.

2. Features: change the display format of data, without changing the original form

 Divided into global and local

  

    <div ID = "App"> 
    <- {{MSG | Upper}} -!>   
      {{MSG | Upper ( "L" )}}

     </ div> 
    <Script the src = "./ the node_modules / VUE / dist /vue.js "> </ Script> 
    <Script> / * filter parameters so added later in the flag * / 
        Vue.filter ( " Upper ", function (value, flag) {
             IF (=== flag 'L ' ) {
                 return value.toLowerCase (); 
            } return value.toUpperCase (); 
        }) 
        the let VM   = new new Vue ({ 
            EL: "#app" ,
                msg:"liLy"

       
            

            data:{
            },/*
            methods:{
                getUpper(){
                    return this.msg.toUpperCase();
                }
            },
            computed:{
                getUpper(){
                    console.log("121");
                    return this.msg.toUpperCase();
                }
            }
            */
        });
    </script>

 

Guess you like

Origin www.cnblogs.com/moon-yyl/p/11755173.html