10_component.html 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. <!DOCTYPE html>
  2. <html lang="en">
  3. <head>
  4. <meta charset="UTF-8">
  5. <meta http-equiv="X-UA-Compatible" content="IE=edge">
  6. <meta name="viewport" content="width=device-width, initial-scale=1.0">
  7. <title>Document</title>
  8. </head>
  9. <body>
  10. <div id="app">
  11. {{msg}}
  12. <my-com></my-com>
  13. <ul>
  14. <li>1</li>
  15. <li>2</li>
  16. <li>3</li>
  17. </ul>
  18. <my-coms name="zhangsan" age="18">
  19. <div>我是HHHHHHHHH</div>
  20. <div>我是XIXIXIXIXIXII</div>
  21. </my-coms>
  22. </div>
  23. <div id="app1">
  24. <my-com></my-com>
  25. </div>
  26. <template id="temp1">
  27. <div>
  28. <h1>{{name}}</h1>
  29. <h1>{{age}}</h1>
  30. <slot></slot>
  31. <h2>我是temp1</h2>
  32. <h3>我是模板</h3>
  33. </div>
  34. </template>
  35. <script src="vue.js"></script>
  36. <script>
  37. /* template 模板 最底层的div */
  38. Vue.component('my-com', {
  39. template: "<h2>hahahhah</h2>"
  40. })
  41. new Vue({
  42. el: '#app',
  43. data: {
  44. msg: 1
  45. },
  46. components: {
  47. 'my-coms': {
  48. template: '#temp1',
  49. props: ['name','age']
  50. }
  51. }
  52. })
  53. new Vue({
  54. el: "#app1"
  55. })
  56. </script>
  57. </body>
  58. </html>