10
0

App.vue 702 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. <template>
  2. <div id="app">
  3. 你好
  4. <!-- 3.在需要的地方使用组件标签 -->
  5. <haha></haha>
  6. <h4 ref="aaa">哈哈哈哈哈哈{{ msg }}</h4>
  7. <button @click="getMain">获取</button>
  8. <Demo2/>
  9. </div>
  10. </template>
  11. <script>
  12. // 1.将组件模块引入
  13. import Demo1 from './components/Demo1.vue'
  14. import Demo2 from './components/Demo2.vue'
  15. export default {
  16. // data:{},
  17. // 为什么vue种data要写成函数呢?
  18. data() {
  19. return {
  20. msg:"放假了"
  21. }
  22. },
  23. created(){},
  24. computed:{},
  25. // 2.将组件注册
  26. components:{
  27. haha:Demo1,
  28. Demo2
  29. },
  30. methods:{
  31. getMain() {
  32. console.log(this.$refs.aaa)
  33. }
  34. }
  35. }
  36. </script>
  37. <style>
  38. </style>