• 组件-全局组件和局部组件


    <!DOCTYPE html>
    <html lang="en">
    <head>
        <meta charset="UTF-8">
        <title>Title</title>
    
    </head>
    <body>
    <div id="seg1">
        <alert></alert>
        <ttt></ttt>
    </div>
    <div id="seg2">
        <alert></alert>
        <ttt></ttt>
    </div>
    <div id="seg3">
        <texts></texts>
    </div>
    
    
    <script src="../lib/vue.js"></script>
    <script src="js/main.js"></script>
    </body>
    </html>
    Vue.component("ttt", {
        template: "<button @click="on_click">全局弹弹弹</button>",
        methods: {
            on_click: function () {
                alert("Yo.")
            }
        }
    });
    
    
    var obj = {
        template: "<button @click="on_click">全局弹弹弹</button>",
        methods: {
            on_click: function () {
                alert("Yo.")
            }
        }
    }
    
    
    
    
    new Vue({
        el: "#seg1",
        components: {
            "alert": {
                template: "<button @click="on_click">弹弹弹</button>",
                methods: {
                    on_click: function () {
                        alert("Yo.")
                    }
                }
            }
        }
    });
    new Vue({
        el: "#seg2",
        components: {
            "alert": {
                template: "<button @click="on_click">弹弹弹</button>",
                methods: {
                    on_click: function () {
                        alert("点你大爷")
                    }
                }
            }
        }
    });
    new Vue({
        el:"#seg3",
        components:{
            "texts":obj
        }
    })
  • 相关阅读:
    (2).net体系
    (1)php开篇常识
    java基础知识-xx
    java基础知识-字符串与数组
    java基础知识-流程控制
    小明的喷漆计划
    加分二叉树
    括号序列
    P1045
    胖男孩
  • 原文地址:https://www.cnblogs.com/52-qq/p/8386296.html
Copyright © 2020-2023  润新知