12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <template>
- <div id="app">
- 你好
- <!-- 3.在需要的地方使用组件标签 -->
- <haha></haha>
-
- <h4 ref="aaa">哈哈哈哈哈哈{{ msg }}</h4>
- <button @click="getMain">获取</button>
- <Demo2/>
- </div>
- </template>
- <script>
- // 1.将组件模块引入
- import Demo1 from './components/Demo1.vue'
- import Demo2 from './components/Demo2.vue'
- export default {
- // data:{},
- // 为什么vue种data要写成函数呢?
- data() {
- return {
- msg:"放假了"
- }
- },
- created(){},
- computed:{},
- // 2.将组件注册
- components:{
- haha:Demo1,
- Demo2
- },
- methods:{
- getMain() {
- console.log(this.$refs.aaa)
- }
- }
- }
- </script>
- <style>
- </style>
|