局部组件.html 557 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. var Child = {
  15. template: '<h2>自定义组件!</h2>'
  16. }
  17. var myApp = new Vue({
  18. el: '#myApp',
  19. data: {
  20. },
  21. components: {
  22. 'runoob': Child
  23. }
  24. });
  25. </script>
  26. </body>
  27. </html>