Vue 组件

35 阅读1分钟
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Vue 组件</title>
    <script type="text/javascript" src="../assets/js/vue.js"></script>
</head>
<body>
<h1>Vue 组件</h1>
<hr>
<div id="app">
   <json>

   </json>
    <whl>

    </whl>
</div>
<div id="aap">
    <json>

    </json>

</div>
</body>
</html>
<script>
    //定义全局组件
    Vue.component('json',{
        template:`<div style="color:red">我是全局的组件</div>`,
    });
    var app = new Vue({
        el:'#app',
        //局部组件
        components:{
            'whl':{
                template:`<div style="color:green">我是局部的组件</div>`,
            }
        }
    });
    var aap = new Vue({
        el:'#aap',
    })
</script>