• VUE3 ref,props,生命周期


    1.--ref属性

     1.1代码

    1.1.1子表

    1. <template>
    2. <div class="person">
    3. <h1>中国</h1>
    4. <h2 ref="title2">北京</h2>
    5. <h3>尚硅谷</h3>
    6. <button @click="showLog">点我输出h2这个元素</button>
    7. </div>
    8. </template>
    9. <script lang="ts" setup name="Person">
    10. import {ref,defineExpose} from 'vue'
    11. // 创建一个title2,用于存储ref标记的内容
    12. let title2 = ref()
    13. let a = ref(0)
    14. let b = ref(1)
    15. let c = ref(2)
    16. function showLog(){
    17. console.log(title2.value)
    18. }
    19. defineExpose({a,b,c})
    20. </script>
    21. <style scoped>
    22. .person {
    23. background-color: skyblue;
    24. box-shadow: 0 0 10px;
    25. border-radius: 10px;
    26. padding: 20px;
    27. }
    28. button {
    29. margin: 0 5px;
    30. }
    31. li {
    32. font-size: 20px;
    33. }
    34. </style>

    1.1.2父表

    
    
    
    

     2.简单回顾TS

    1.子

    
    
    
    
    
    
    
    
    

     2.TS

    export interface PersonInter {
      id:string,
      name:string,
      age:number
    }
    
    // 一个自定义类型
    // export type Persons = Array
    export type Persons = PersonInter[]

     3.props的使用

    1.1子表

    
    
    
    
    

     1.2父表

    
    
    
    

    2.TS

    // 定义一个接口,用于限制person对象的具体属性
    export interface PersonInter {
      id:string,
      name:string,
      age:number,
    }
    
    // 一个自定义类型
    // export type Persons = Array
    export type Persons = PersonInter[]

    4. 对生命周期的理解

    1.vue3


    1. 子表

    
    
    
    
    

    2.父表

    
    
    

  • 相关阅读:
    Hamiton图系列文章 (1) Hamilton图证明算法的道路矩阵基础数据结构与类的设计
    Prometheus&Alertmanager告警推送
    G. The Great Equalizer
    微信小程序模板全行整理合集
    选择排序--python(详解)
    应用开发平台集成表单设计器系列之3——整体集成思路及表单设计器功能深度了解
    C和指针——struct结构
    后厂村路灯在线签名网站,在线签名工具,IPA在线签名
    二进制信号量
    英语语音篇 - 看词能读
  • 原文地址:https://blog.csdn.net/TA016422/article/details/138012614