全局组件.html 592 B

12345678910111213141516171819202122232425262728293031
  1. <!DOCTYPE html>
  2. <html lang="zh">
  3. <head>
  4. <title></title>
  5. <meta charset="UTF-8">
  6. <meta name="viewport" content="width=device-width, initial-scale=1">
  7. <script src="https://unpkg.com/vue/dist/vue.js"></script>
  8. <link href="../css/style.css" rel="stylesheet"> </head>
  9. <body>
  10. <div id="myApp">
  11. <runoob>哈哈</runoob>
  12. </div>
  13. <script>
  14. // 先注册component
  15. Vue.component('runoob', {
  16. template: '<h2>自定义组件!</h2>'
  17. })
  18. // 然后实例化一个vue对象
  19. var myApp = new Vue({
  20. el: '#myApp',
  21. data: {
  22. },
  23. });
  24. </script>
  25. </body>
  26. </html>