欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

vue3動態(tài)組件使用詳解

 更新時間:2023年02月27日 08:17:53   作者:不叫貓先生  
這篇文章主要介紹了vue3動態(tài)組件使用詳解的相關(guān)資料,需要的朋友可以參考下
  • markRow:標(biāo)記一個對象,使其不能成為一個響應(yīng)式對象。
  • toRaw:將響應(yīng)式對象(由 reactive定義的響應(yīng)式)轉(zhuǎn)換為普通對象。
  • shallowRef:只處理基本數(shù)據(jù)類型的響應(yīng)式, 不進行對象的響應(yīng)式處理。
  • shallowReactive:只處理對象最外層屬性的響應(yīng)式(淺響應(yīng)式)。

??問題:為什么vue3需要對引入的組件使用markRow???

vue2

<template>
<div>
<component :is="A"></component>
</div>
</template>

<script>
import A from './A';
export default {
name: 'Home',
data() {
return {}
},
components: { A },
}

vue3

<template>
<ul>
<li
v-for='(item,index) in tabList'
:key='index'
@click='change(index)'
>
{{ item.name }}
</li>
</ul>
<keep-alive>
<component :is="currentComponent"></component>
</keep-alive>
</template>

<script setup>
import A from '../components/A.vue'
import B from '../components/B.vue'
import C from '../components/C.vue'
let tabList = reactive([
{name:'組件A',com:markRaw(A)},
{name:'組件B',com:markRaw(B)},
{name:'組件C',com:markRaw(C)}
]);
let currentComponent = reactive({
com:tabList[0]
});
const change = ( idx )=>{
currentComponent = tabList[idx].com;
}

到此這篇關(guān)于vue3動態(tài)組件使用詳解的文章就介紹到這了,更多相關(guān)vue3動態(tài)組件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!

相關(guān)文章

最新評論