Use of the data component Vue.js

<!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>
    <script src="./lib/Vue.js"></script>
</head>

<body>
    <div id="app">
        <connter></connter>
        <hr>
        <connter></connter>
        <hr>
        <connter></connter>
    </div>

    <the above mentioned id = Template "tmp"> 
                must be an object inside, otherwise If you repeatedly use a same component, then the component the event will interfere with each other ->
            <the INPUT of the type = "the Button" value = "+ 1" = @ the Click "TT">
        <div>
            <-! exactly the same method used in Example data in the assembly, but the assembly the data must be a Function, and the return value 
            <h1> {{COUNT}} </ h1> 
        </ div> 
    </ Template> 
</ body> 
<Script> 
    var dt = { 
        COUNT: 0 
    } 

    Vue.component ( 'connter', { 
        Template: '#tmp', 
        Data () { 
            // return dt 
            return { 

                COUNT: 0 
            } 
        }, 
        Methods: { 
            TT () { 
                this.count ++ 
            } 
        } 
    }) 

    var Vue new new VM = ({ 
        EL: '#app',
        data: {

        },
        methods: {

        }
    })
</script>

</html>

 

Guess you like

Origin www.cnblogs.com/LittleDuan/p/11330857.html