首页 > Web开发 > 详细

参考书籍《Vue.js快跑:构建触手可及的高性能Web应用》第2章 组件-----2-1组件基础

时间:2021-06-25 22:24:27      阅读:23      评论:0      收藏:0      [点我收藏+]
<!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>组件基础</title>
</head>

<body>
    <div id="app">
        <button-component></button-component>
        <custom-button></custom-button>
    </div>
    <script src="../vue.js"></script>
    <script>

        // 注册全局组件
        Vue.component(button-component, {
            template: <button>全局组件按钮</button>
        })


        // 局部注册组件
        // 注意局部注册的组件在其子组件中不可用。
        const CustomButton = {
            template: <button>局部注册组件按钮</button>
        };


        let vue = new Vue({
            el: "#app",
            data: {

            },
            components: {   // 注册组件
                custom-button: CustomButton
            }
        })
    </script>
</body>

</html>

 

参考书籍《Vue.js快跑:构建触手可及的高性能Web应用》第2章 组件-----2-1组件基础

原文:https://www.cnblogs.com/cuilichao/p/14932253.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!