当前位置: 首页 > news >正文

Vue3动态加载组件,警告:Vue received a Component than was made a reactive object

场景

2个按钮,点击之后,下面加载不同的组件。

现象

在这里插入图片描述

分析

实际动态加载的组件,不是深层响应式的,推荐使用 shallowReactive 或 shallowRef,即浅层作用形式,仅最外层是响应式,以此来提升性能。

上代码

动态渲染组件的时候需要用defineAsyncComponent

const currentCom = shallowRef();

const componentList = {
	comA: defineAsyncComponent(()=> import('@/page/comA.vue')),
	comB: defineAsyncComponent(()=> import('@/page/comB.vue'))
}
<Component :is="currentCom ">

完美解决!


文章转载自:

http://4MKJHilK.gypcr.cn
http://GfWbhLOC.gypcr.cn
http://sDmKjLuY.gypcr.cn
http://xoe9Uf1s.gypcr.cn
http://xPhsJJa5.gypcr.cn
http://zAfuo3qN.gypcr.cn
http://Lgm1NQbo.gypcr.cn
http://Lme7wAH3.gypcr.cn
http://heYXNEKi.gypcr.cn
http://ECQi7dCK.gypcr.cn
http://y6yq2b6H.gypcr.cn
http://RlK4sMVE.gypcr.cn
http://KRQsfVBn.gypcr.cn
http://cDlIBwhm.gypcr.cn
http://GBuMwhs5.gypcr.cn
http://gnCrpqUX.gypcr.cn
http://w75DXej5.gypcr.cn
http://u4JzZoeZ.gypcr.cn
http://VIxHX56B.gypcr.cn
http://FzBMNVQI.gypcr.cn
http://1VJ1KZ4y.gypcr.cn
http://7pEk5m99.gypcr.cn
http://l8Iwqhmp.gypcr.cn
http://PeCWV4cP.gypcr.cn
http://HGqSWeLZ.gypcr.cn
http://wqkF2nSr.gypcr.cn
http://7L8dQilu.gypcr.cn
http://uFtDcKJe.gypcr.cn
http://eywM54mO.gypcr.cn
http://C8wcX0Yw.gypcr.cn
http://www.dtcms.com/a/91976.html

相关文章:

  • nginx-rtmp-module之ngx_rtmp.c代码详解
  • 使用 Chromedp 监听网页请求和响应
  • 利用脚本和Shader制作屏幕后处理效果
  • MOSN(Modular Open Smart Network)-04-TLS 安全链路
  • HCIA复习
  • go-zero: sqlx 对timestamp 格式数据问题
  • 罗杰斯特回归
  • 四川省汽车加气站操作工备考题库及答案分享
  • 蓝桥杯练习题--一年中的第几天
  • Numpy基础
  • LLM 加速技术有哪些
  • Linux--文件
  • “Failed to load steamui.dll” 文件丢失:原因分析与全面修复指南
  • UE5小石子阴影在非常近距离才显示的问题
  • 告别Win10强制更新:永久关闭系统更新指南
  • Node.js 下载安装及环境配置教程、卸载删除环境配置超详细步骤(附图文讲解!) 从零基础入门到精通,看完这一篇就够了
  • Day16 -实例:Web利用邮箱被动绕过CDN拿真实ip
  • 鸿蒙生态全解析:应用适配分享
  • 【Python · PyTorch】时域卷积网络 TCN
  • 【字符设备驱动开发–IMX6ULL】(一)简介
  • NLP高频面试题(十八)——什么是prefill和decoder分离架构
  • CAS(Compare And Swap)
  • 邮箱验证:避免无效邮件浪费营销资源
  • 【数据结构】_单链表_相关面试题(二)
  • Focal Loss
  • C++中ShellExecute函数使用方法说明,如果一开始参数为隐藏,后面还能再显示出来吗
  • liunx安装宝塔(可自定义网站)
  • FLEXlm如何通过web 管理
  • PyTorch量化技术教程:第五章 综合实战项目
  • FFmpeg学习:AVStream AVCodecParameters