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

学习NuxtLink标签

我第一次接触这个标签,我都不知道是干嘛的,哈哈哈哈,就是他长得有点像routerLink,所以我就去查了一下!哎!!!真是一样的,哈哈哈哈,至少做的事情是一样的!这就通透啦~

简单来说这个东西就是一个切换路由的东西。

<template><div><h1>Home page</h1><nuxt-link to="/about">关于</nuxt-link></div>
</template>

这样点击关于这俩字的时候就会跳转到/about这个页面。

要禁用链接页面的预获取,可以使用no-prefetch

<n-link to="/about" no-prefetch>About page not pre-fetched</n-link>

我自己也写了一段代码,可以直接看效果!

<template><div class="container"><h2 class="title">储存容量</h2><div class="button-group"><NuxtLinkv-for="size in storageOptions":key="size.value":to="size.value"class="button":class="{ active: isActive(size.value) }">{{ size.text }}</NuxtLink></div></div>
</template><script setup lang="ts">
import { computed } from 'vue';
import { useRoute } from 'vue-router';const route = useRoute();const storageOptions = [{ text: '128GB', value: '128gb' },{ text: '256GB', value: '256gb' },{ text: '512GB', value: '512gb' },
];const currentStorage = computed(() => {const storageParam = route.params.storage;if (Array.isArray(storageParam)) {return storageParam[0] || '';}return storageParam || '';
});const isActive = (value: string) => {return currentStorage.value.toLowerCase() === value.toLowerCase();
};
</script><style scoped>
.container {display: flex;flex-direction: column;align-items: center;justify-content: center;height: 100vh;text-align: center;
}.title {margin-bottom: 20px;font-size: 1.5em;
}.button-group {display: flex;gap: 10px;
}.button {padding: 10px 20px;border: 1px solid #ccc;border-radius: 5px;text-decoration: none;color: #333;background-color: #f9f9f9;cursor: pointer;transition: background-color 0.3s, color 0.3s;
}.button:hover {background-color: #e0e0e0;
}.button.active {background-color: #007bff;color: white;border-color: #007bff;
}
</style>

http://www.xdnf.cn/news/10698.html

相关文章:

  • dvwa6——Insecure CAPTCHA
  • Lovable + Cursor:零基础搭建专业应用的秘密武器
  • Windows下WSL(Ubuntu)安装1Panel
  • ASR技术(自动语音识别)深度解析
  • Eigen实现非线性最小二乘拟合 + Gauss-Newton算法
  • RabbitMQ如何保证消息可靠性
  • python中可以对数组使用的所有方法
  • 工作自动化——工作自动提炼--智能编程——仙盟创梦IDE
  • B站缓存视频数据m4s转mp4
  • 从零开始,搭建一个基于 Django 的 Web 项目
  • django入门-orm数据库操作
  • unity UI Canvas“高”性能写法
  • 如何轻松地将数据从 iPhone传输到iPhone 16
  • 【JSON-to-Video】设置背景视频片断
  • 【OCCT+ImGUI系列】011-Poly-Poly_Triangle三角形面片
  • GIC v3 v4 虚拟化架构
  • 业态即战场:零售平台的生意模型与系统设计解构
  • Elasticsearch集群最大分片数设置详解:从问题到解决方案
  • [特殊字符] Unity UI 性能优化终极指南 — ScrollRect篇
  • spring-boot-admin实现对微服务监控
  • 提升四级阅读速度方法
  • python学习(一)
  • git checkout C1解释
  • Windows 下彻底删除 VsCode
  • 开疆智能Profinet转Profibus网关连接CMDF5-8ADe分布式IO配置案例
  • RequestRateLimiterGatewayFilterFactory
  • 亚马逊Woot提报常见问题第一弹
  • es 的字段类型(text和keyword)
  • PostgreSQL的扩展 passwordcheck
  • 深入剖析物联网边缘计算技术:架构、应用与挑战