Some examples of methods Vue body (a)

<!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"></div>
</body>
</html>
<script src="./vue.js"></script>
<script>
    var vm = new Vue({
        el:"#app"
    })


    function fn1(val){
        console.log(111,val)
    }

    function fn2(val){
        console.log(222 , Val) 
    } 

    function Fn3 (Val) { 
        the console.log ( 333 , Val) 
    } 

    // VM. $ ON ( "handle", Fn1) 
    // VM. $ ON ( "handle", Fn2) 
    // VM. ON $ ( "handle", fn3) 
   // vm. $ OFF ( "handle", fn2) 


    vm. $ Once ( "handle" , fn1) 
    vm. $ Once ( "handle" , fn2) 
    vm. Once $ ( " handle " , fn3) 
    . vm $ EMIT ( " handle "," Do not go to bed, okay " ) 
    vm $ EMIT (. " handle "," Do not go to bed, okay " ) 
    


    / * 
        vm $ ON.:Listen for the event 
            parameter 1: The name of the event   
            function needed: Parameter 2


        vm $ once:. listen to events will only monitor a 
            parameter 1: The name of the event   
            parameter 2: function requires binding 


        vm $ off:. unbundling event 
            parameter 1: the need for unbundling of the event (if parameter 2 does not exist All unbundling) 
            parameter 2: need to solve function tied 



        vm $ emit:. handle the event 
            parameter 1: the name of the event to be triggered 
            parameter 2: parameters need to pass 

    
    * / 
</ Script>

 

Guess you like

Origin www.cnblogs.com/r-mp/p/11224211.html