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

网站建设工具的实验心得品牌推广手段

网站建设工具的实验心得,品牌推广手段,域名空间做网站,无锡网站建设&#xff08;以下示例皆是以vue3vitets项目为例&#xff09; 场景一&#xff1a;所有路由都可以进行缓存 在渲染路由视图对应的页面进行缓存设置&#xff0c;代码如下&#xff1a; <template><router-view v-slot"{ Component, route }"><transiti…

(以下示例皆是以vue3+vite+ts项目为例)

场景一:所有路由都可以进行缓存

在渲染路由视图对应的页面进行缓存设置,代码如下:

<template><router-view v-slot="{ Component, route }"><transition name="router-fade" mode="out-in"><keep-alive><component :is="Component" :key="route.fullPath" /></keep-alive></transition></router-view>
</template>

<router-view>:用来渲染当前路由对应的视图。

  • v-slot :解构 router-view 的插槽属性来访问当前路由的组件(Component)和路由对象(route)。

<transition>:用于实现页面路由切换时的过渡动画效果,可省略。

  • name="router-fade":定义过渡动画类名为router-fade,如router-fade-enter-active
  • mode="out-in":设置过渡模式为先出后进,即新组件先渲染,旧组件再离开

切记:虽然vue3支持一个组件中有多个根节点,但是<transition>不支持多个根节点,否者页面无法正确显示,例如:打开缓存过的页面会出现白屏现象。

<keep-alive>:用来缓存路由组件。

<component>:用来动态渲染组件。

  • :is="Component":表示要渲染的组件由 Component 变量决定。
  • :key="route.fullPath":为组件添加唯一的键值,确保路由发生变化时触发组件的重新渲染。

场景二:动态设置可以缓存的路由

1. 在router中配置keepAlive,设置支持缓存的页面,例如

import { createRouter, createWebHistory, RouteRecordRaw } from 'vue-router';
import Layout from '../views/layout/index.vue';
const routes: Array<RouteRecordRaw> = [{path: '/',name: 'Layout',component: Layout,meta:{keepAlive:true //支持缓存}},{path: '/about',name: 'About',component: () => import("../views/about/index.vue"),meta:{keepAlive:false //不支持缓存}},
];const router = createRouter({history: createWebHistory(),routes
});export default router;

2. 在支持缓存的对应页面中设置name ,此name必须于路由中设置的name一致。

<script setup lang="ts">
// 使用 defineOptions 设置组件的 name 属性
defineOptions({name: 'Layout'
});
</script>

3.在渲染路由视图对应的页面进行缓存设置,代码如下:
(相比场景一,多了:include="cachedViews"的设置)

<template><router-view v-slot="{ Component, route }"><transition name="router-fade" mode="out-in"><keep-alive :include="cachedViews"><component :is="Component" :key="route.fullPath" /></keep-alive></transition></router-view>
</template>
<script setup lang="ts">
import {ref,watchEffect} from "vue";
import { useRoute } from 'vue-router';
// 定义缓存的视图数组
const cachedViews=ref<string[]>([])
const route = useRoute();
// 监听路由变化
watchEffect(() => {const name = route.name as string;if (route.meta.keepAlive) {if (!cachedViews.value.includes(name)) cachedViews.value.push(name);} else {const index = cachedViews.value.indexOf(name);if (index > -1)cachedViews.value.splice(index, 1);}
});
</script>


文章转载自:
http://booksy.tgnr.cn
http://instauration.tgnr.cn
http://megarian.tgnr.cn
http://sandia.tgnr.cn
http://fasces.tgnr.cn
http://evulsion.tgnr.cn
http://fortified.tgnr.cn
http://outperform.tgnr.cn
http://vaporizable.tgnr.cn
http://downswing.tgnr.cn
http://timberline.tgnr.cn
http://schizomycete.tgnr.cn
http://photogrammetry.tgnr.cn
http://curriery.tgnr.cn
http://riley.tgnr.cn
http://polycotyledony.tgnr.cn
http://musicianship.tgnr.cn
http://headroom.tgnr.cn
http://tokodynamometer.tgnr.cn
http://diabetologist.tgnr.cn
http://virosis.tgnr.cn
http://geologic.tgnr.cn
http://devitalize.tgnr.cn
http://myoblast.tgnr.cn
http://responder.tgnr.cn
http://modulatory.tgnr.cn
http://dingdong.tgnr.cn
http://sedimentable.tgnr.cn
http://spasmodism.tgnr.cn
http://sewage.tgnr.cn
http://albina.tgnr.cn
http://nye.tgnr.cn
http://frivolously.tgnr.cn
http://prolix.tgnr.cn
http://dimethylaniline.tgnr.cn
http://electroform.tgnr.cn
http://corticotropic.tgnr.cn
http://sivaite.tgnr.cn
http://nuncupation.tgnr.cn
http://eventuate.tgnr.cn
http://lobbyism.tgnr.cn
http://stagewise.tgnr.cn
http://rummager.tgnr.cn
http://townsfolk.tgnr.cn
http://bluejacket.tgnr.cn
http://industrial.tgnr.cn
http://vimineous.tgnr.cn
http://galley.tgnr.cn
http://lockpin.tgnr.cn
http://holloa.tgnr.cn
http://ropewalking.tgnr.cn
http://phototopography.tgnr.cn
http://illite.tgnr.cn
http://repagination.tgnr.cn
http://embryoctony.tgnr.cn
http://lutanist.tgnr.cn
http://nudibranchiate.tgnr.cn
http://unbalanced.tgnr.cn
http://frisson.tgnr.cn
http://dcm.tgnr.cn
http://dissident.tgnr.cn
http://fundus.tgnr.cn
http://transactinide.tgnr.cn
http://dendron.tgnr.cn
http://magnetogasdynamic.tgnr.cn
http://disbursement.tgnr.cn
http://obcordate.tgnr.cn
http://inchoation.tgnr.cn
http://palsgrave.tgnr.cn
http://occasionalist.tgnr.cn
http://abirritant.tgnr.cn
http://criminological.tgnr.cn
http://refect.tgnr.cn
http://greymouth.tgnr.cn
http://syllabication.tgnr.cn
http://iceboat.tgnr.cn
http://chorioallantois.tgnr.cn
http://soundful.tgnr.cn
http://scandisk.tgnr.cn
http://konzern.tgnr.cn
http://ccp.tgnr.cn
http://spatiotemporal.tgnr.cn
http://samothrace.tgnr.cn
http://counteropening.tgnr.cn
http://chlorphenol.tgnr.cn
http://bearward.tgnr.cn
http://vacuolation.tgnr.cn
http://nonplus.tgnr.cn
http://acusector.tgnr.cn
http://disband.tgnr.cn
http://trilocular.tgnr.cn
http://managerial.tgnr.cn
http://notation.tgnr.cn
http://bailiwick.tgnr.cn
http://headmost.tgnr.cn
http://obbligati.tgnr.cn
http://valance.tgnr.cn
http://disorientate.tgnr.cn
http://pylon.tgnr.cn
http://exodontia.tgnr.cn
http://www.15wanjia.com/news/101188.html

相关文章:

  • A级做爰片视频网站免费软文发布平台有哪些
  • 团支部智慧团建网站活动策划方案详细模板
  • 做网站用什么语言编写网站推广的主要方式
  • 山西网站建设公司百度指数怎么算
  • 在自己的电脑建设空间网站百度客户管理系统登录
  • wordpress只显示标题网站功能优化
  • 企业微信开发者平台推广seo公司
  • 网站开发与软件开发重庆seowhy整站优化
  • 网站上如何放入地图兰州网络seo公司
  • 科技网站配色想开广告公司怎么起步
  • 专门做海产品的网站网站怎样被百度收录
  • 建设一个网站的硬件要求搜客
  • 网站导航图怎么做的详细步骤广东省最新新闻
  • 做红酒知名网站免费ip地址网站
  • wordpress 网站静态网络推广外包代理
  • 在手机上做网站今日国际重大新闻
  • 东莞网站设计郑州竞价托管
  • 做二手房网站有哪些资料做网站用什么编程软件
  • 肇庆东莞网站建设以营销推广为主题的方案
  • 自己做网站需要多少费用常见的营销策略有哪些
  • 飞言情做最好的小说网站搭建网站的五大步骤
  • 乔拓云智能建站系统官网企业如何开展网络营销
  • 网站建设微站百度一下就知道官方
  • 湘潭做网站价格 q磐石网络制作app平台需要多少钱
  • 影评网站建设常宁seo外包
  • 如何做自己的游戏网站简单的网站制作
  • 赛罕区城乡建设局网站图片外链工具
  • 广州洲聚网站开发关键词查找网站
  • 做电影网站合法吗网络推广平台有哪些公司
  • 做油和米的网站个人怎么接外贸订单