<output id="qn6qe"></output>

    1. <output id="qn6qe"><tt id="qn6qe"></tt></output>
    2. <strike id="qn6qe"></strike>

      亚洲 日本 欧洲 欧美 视频,日韩中文字幕有码av,一本一道av中文字幕无码,国产线播放免费人成视频播放,人妻少妇偷人无码视频,日夜啪啪一区二区三区,国产尤物精品自在拍视频首页,久热这里只有精品12

      vue3簡(jiǎn)明教程實(shí)踐

      // ParentComponent
      <script setup lang="ts">
      // reactive 創(chuàng)建響應(yīng)式對(duì)象數(shù)據(jù)
      import {ref, reactive, toRefs, computed, watch, onMounted, provide } from 'vue';
      // 一般創(chuàng)建簡(jiǎn)單類型的數(shù)據(jù),例如字符串、布爾值等
      const number = ref(0);
      const changeNumber = () => {
        // 修改數(shù)據(jù)必須加上.value
        number.value++
      }
      // 一般用來(lái)創(chuàng)建對(duì)象、數(shù)組類型數(shù)據(jù)
      const userInfo = reactive({
        name: 'leyi',
        role: 'front-developer',
        introduce: 'nobody'
      })
      const changeUserInfo = () => {
        userInfo.introduce = 'my name is leyi, i was born in sichuan'
      }
      
      // 解構(gòu)reactive創(chuàng)建的響應(yīng)式對(duì)象
      const { name, role, introduce } = toRefs(reactive({
        name: 'leyi',
        role: 'front-developer',
        introduce: ''
      }))
      const changeUserInfoDeconstruction = () => {
        introduce.value = 'a province well know for its spicy food'
        console.log(userInfo.introduce) // 檢查是否執(zhí)行
      }
      // 計(jì)算屬性
      const tripledNumber = computed(() => number.value + 3)
      
      // 數(shù)據(jù)監(jiān)聽 類似effect
      watch(number, (newValue, olValue) => {
        console.info('number changed', newValue, olValue)
      })
      
      // 父組件穿傳遞數(shù)據(jù)給子組件
      import ChildComponent from './myComponents/ChildComponent.vue'
      
      // 獲取子組件傳遞過來(lái)的數(shù)據(jù)
      const getChildData = (data) => {
      console.info('data from child', data)
      }
      
      // 通過ref獲取組件實(shí)例Dom
      const btnRef = ref(null)
      onMounted(() => {
        console.info('btnRef', btnRef.value)
      })
      
      // 調(diào)用子組件里的方法 子組件通過defineExpose進(jìn)行暴露
      const childComponentRef = ref(null)
      const changeChildComponentContent = () => {
        childComponentRef.value.changeContent()
      }
      
      // 通過provide往下傳遞數(shù)據(jù),所有子孫組件都能接收到 類似于contextProvider
      provide("list", [5,6,7,8,9])
      </script>
      
      <template>
      <div>
        {{ number }}
        <button @click="changeNumber">modify number</button>
      </div>
      <div>
        {{ userInfo.name }}
        {{ userInfo.role }}
        {{ userInfo.introduce}}
        <button @click="changeUserInfo">modify userInfo</button>
      </div>
      <div>
        {{ name }}
        {{ role }}
        {{ introduce }}
        <button @click="changeUserInfoDeconstruction">modify userInfo deconstruction</button>
      </div>
      <div>
        {{ tripledNumber }}
      </div>
      <div>
        <ChildComponent :data="userInfo" @getChildData="getChildData"  ref="childComponentRef"/>
      </div>
      <div>
        <button ref="btnRef">get current ref instance dom </button>
      </div>
      <div>
        <button @click="changeChildComponentContent"> invoke function or attribute of  child component</button>
      </div>
      </template>
      
      // ChildComponent
      <script setup>
      import { ref, inject } from 'vue'
      // 通過props從父組件獲取數(shù)據(jù)
      const props = defineProps(['data'])
      console.info('props', props.data.name)
      // 通過emit注冊(cè)事件向父組件傳遞數(shù)據(jù)
      const emit = defineEmits(['getChildData'])
      const sendMessage = () => {
        emit('getChildData', [1,2,3,4,5])
      }
      
      // 通過defineExpose向父組件暴露方法或?qū)傩?const content = ref('hello world')
      const changeContent = () => {
        content.value = 'hello leyi'
      }
      defineExpose({
        content,
        changeContent,
      })
      
      // 通過inject接收數(shù)據(jù)
      console.info('received data from above components', inject('list'))
      </script>
      <template>
      <button @click="sendMessage">send data to parent component</button>
      {{ content }}
      </template>

       

      參考文檔:https://mp.weixin.qq.com/s/_f9g9kiaG1HmG-KXHjgCRw

      posted @ 2025-07-25 13:51  韭菜茄子  閱讀(6)  評(píng)論(0)    收藏  舉報(bào)
      主站蜘蛛池模板: 樱桃视频影院在线播放| 成年在线观看免费人视频| 十八禁国产精品一区二区| 国产亚洲欧美日韩在线一区二区三 | 亚洲成在人线AⅤ中文字幕| 99re热这里只有精品视频| av中文字幕一区人妻| 大香伊蕉在人线国产最新2005 | 日韩精品一区二区亚洲专区| 精品亚洲精品日韩精品| 国产精品一区二区三区色| 亚洲av日韩av永久无码电影 | 麻花传媒在线观看免费| 亚洲一区二区三区自拍麻豆| 亚洲午夜香蕉久久精品| 天堂mv在线mv免费mv香蕉| 久久婷婷大香萑太香蕉AV人| 在线a亚洲v天堂网2018| 日本视频一区二区三区1| 亚洲第一天堂无码专区| 国产对白老熟女正在播放| 国产精品无码dvd在线观看| 狠狠色综合tv久久久久久| 国产精品无码一区二区在线 | 中文字幕亚洲制服在线看| 国产精品SM捆绑调教视频| 福利一区二区在线播放| 新版天堂资源中文8在线| 色诱视频在线观看| 92精品国产自产在线观看481页| 水城县| 久久国产精品精品国产色| 国产一区二区三区导航| 亚洲男人AV天堂午夜在| 猫咪AV成人永久网站在线观看| 色777狠狠狠综合| 中文字幕日韩精品国产| 影视先锋av资源噜噜| 国产亚洲一二三区精品| 国产成人无码免费看片软件| 国产蜜臀在线一区二区三区|