zoukankan      html  css  js  c++  java
  • Vue:全局组件与局部组件

    全局组件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <div id="seg1">
        <alert></alert>
    </div>
    
    <script src="https://cdn.bootcss.com/vue/2.4.2/vue.js"></script>
    <script>
        Vue.component(
            'alert',{
                template:
                    '<button @click="on_click">弹弹弹</button>'
                ,
                methods:{
                    on_click:function () {
                        alert('Yo.');
                    }
                }
            }
        );
        new Vue({
            el:"#seg1"
        })
    </script>
    </body>
    </html>

    局部组件

    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    </head>
    <body>
    <div id="seg1">
        <alert></alert>
    </div>
    
    <script src="https://cdn.bootcss.com/vue/2.4.2/vue.js"></script>
    <script>
       var alert_component={
                template:
                    '<button @click="on_click">弹弹弹</button>'
                ,
                methods:{
                    on_click:function () {
                        alert('Yo.');
                    }
                }
            };
    
        new Vue({
            el:"#seg1",
            componets:{
                alert:alert_component
            }
        })
    </script>
    </body>
    </html>
  • 相关阅读:
    《原则》读书笔记
    mvn + testng + allure 生成自动化测试报告
    poj3264RMQ
    poj3928pingpong区间和
    uva11361数位dp
    Poj2795Exploring PyramidsDp
    uva11137Dp
    uva11375Dp
    三道组合题
    poj1379模拟退火
  • 原文地址:https://www.cnblogs.com/c491873412/p/7455038.html
Copyright © 2011-2022 走看看