2023年7月11日
摘要: 在大型项目中,我们可能需要拆分应用为更小的块,并仅在需要时再从服务器加载相关组件。Vue 提供了 defineAsyncComponent 方法来实现此功能: 1 <template> 2 <h3>异步加载</h3> 3 <KeepAlive> 4 <component :is="tabCompon 阅读全文
posted @ 2023-07-11 17:43 wuzx-blog 阅读(99) 评论(0) 推荐(0) 编辑
摘要: <KeepAlive> 是一个内置组件,它的功能是在多个组件间动态切换时缓存被移除的组件实例 1、不使用KeepAlive,组件不保持存活,验证如下: A组件 1 <template> 2 <h3>ComponentA</h3> 3 <p>{{ message }}</p> 4 <button @c 阅读全文
posted @ 2023-07-11 17:28 wuzx-blog 阅读(83) 评论(0) 推荐(0) 编辑
摘要: A组件 1 <template> 2 <h3>ComponentA</h3> 3 </template> B组件 1 <template> 2 <h3>ComponentB</h3> 3 </template> App.vue 1 <template> 2 <h3>动态组件(A、B两个组件动态切换) 阅读全文
posted @ 2023-07-11 17:05 wuzx-blog 阅读(77) 评论(0) 推荐(0) 编辑
摘要: 1 <template> 2 <h3>组件生命周期函数应用</h3> 3 <!--验证Dom结构加载时机--> 4 <p ref="name">我的内容</p> 5 <!--模拟网络加载数据--> 6 <ul> 7 <li v-for="(item,index) in banner" :key="i 阅读全文
posted @ 2023-07-11 16:12 wuzx-blog 阅读(17) 评论(0) 推荐(0) 编辑