vue global components

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/caoxuecheng001/article/details/102757657
<div id="app">
    <counter></counter>
    <counter></counter>
    <counter></counter>
</div>

<script src="node_modules/vue/dist/vue.js"></script>
<script>
    Vue.component("counter",{
        template:"<button @click='count++'>点我试试,已经点击{{count}}次</button>",
        data(){
            return{
                count:0
            }

        }
    });
   const app=new Vue({
       el:"#app",
       data:{

       }

   });
</script>

 

Guess you like

Origin blog.csdn.net/caoxuecheng001/article/details/102757657