Vue example (3-1)

Vue instance

It's still specific to look at the Vue example.
el and data are its attributes.
method is the method.
component is a template attribute. Its item actually defines the label

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src='./vue.js'></script>
</head>
<body>
    
    <div id="root">
        <div @click="handleClick">
            {
   
   {message}}
        </div>
        <item></item>
    </div>

    <script>

        Vue.component('item', {
     
     
            template: '<div>hello world</div>'
        })

        var vm = new Vue({
     
     
            el: '#root',
            data: {
     
     
                message: 'hello world'
            },
            methods: {
     
     
                handleClick: function() {
     
     
                    alert("hello")
                }
            }
        })
    </script>
</body>
</html>

Guess you like

Origin blog.csdn.net/weixin_45647118/article/details/113828465
Recommended