DeepSeek 助力 Vue 开发:打造丝滑的点击动画(Click Animations)

前言:哈喽,大家好,今天给大家分享一篇文章!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦 💕

共同探索软件研发!敬请关注【宝码香车】
关注描述

csdngif标识

目录

  • DeepSeek 助力 Vue 开发:打造丝滑的点击动画(Click Animations)
    • 📚前言
    • 📚页面效果
    • 📚指令输入
      • 属性定义
        • 1. 动画类型相关属性
        • 2. 样式相关属性
        • 3. 动画次数和循环相关属性
        • 4. 状态控制属性
      • 事件定义
        • 1. 动画开始事件
        • 2. 动画结束事件
        • 3. 点击事件
      • 其他
        • 1. 兼容性处理
        • 2. 文档和示例
        • 3. 性能优化
        • 4. 可扩展性
        • 5. 错误处理
    • 📚think
      • 📘组件代码
    • 📚代码测试
    • 📚整理后主要代码
      • 📘定义组件 src\components\ClickAnimations\ClickAnimations.vue
      • 📘调用 src\views\ClickAnimationsView.vue
    • 📚为测试代码正常跑通,附其他基本代码
      • 📘编写路由 src\router\index.js
      • 📘编写展示入口 src\App.vue
    • 📚页面效果


📚📗📕📘📖🕮💡📝🗂️✍️🛠️💻🚀🎉🏗️🌐🖼️🔗📊👉🔖⚠️🌟🔐⬇️·正文开始⬇️·🎥😊🎓📩😺🌈🤝🤖📜📋🔍✅🧰❓📄📢📈 🙋0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣🔟🆗*️⃣#️⃣

DeepSeek 助力 Vue 开发:打造丝滑的点击动画(Click Animations)

📚前言

在社交媒体和各类技术论坛上,用户对 DeepSeek 的评价如潮水般涌来,其中不乏对其强大功能和出色表现的高度赞誉。许多用户分享了自己使用 DeepSeek 解决实际问题的案例,这些案例生动地展现了 DeepSeek 在不同领域的应用价值。

在学术研究领域,一位生物学博士分享了他的经历。他在研究一种罕见疾病的发病机制时,需要查阅大量的文献资料。以往,他需要花费数周的时间在海量的学术论文中筛选和整理信息,而这次他借助 DeepSeek,仅用了几天的时间就完成了这项工作。DeepSeek 不仅能够快速准确地理解论文的内容,还能根据他的研究需求,提供相关的研究思路和建议。例如,在分析一篇关于基因调控的论文时,DeepSeek 能够指出论文中尚未深入探讨的潜在研究方向,为他的研究提供了新的灵感。他感慨地说:“DeepSeek 就像是我的学术助手,大大提高了我的研究效率,让我能够更专注于实验和数据分析。”

📚页面效果

页面效果

📚指令输入

已经创建好了一个基于Vue3的组合式API的项目(Composition API),并能正常运行起来,请帮我用 Vue3的组合式API(Composition API) 生成一个 点击动画(Click Animations) 的功能组件,所有代码都保存在components/ClickAnimations 下的文件夹中。功能组件的script标签中只有setup属性,使用普通 JavaScript 实现,不使用TypeScript。
功能要有,如下属性:

属性定义

1. 动画类型相关属性
  • animationType:指定点击时触发的动画类型,如 fade(淡入淡出)、scale(缩放)、slide(滑动)等。可以使用字符串类型,方便后续扩展更多动画类型。
  • animationDuration:动画持续的时间,单位可以是毫秒(ms)。使用数字类型,让用户可以自定义动画的快慢。
  • animationDelay:动画开始前的延迟时间,单位同样为毫秒(ms)。用户可以根据需要设置动画触发的时机。
2. 样式相关属性
  • targetElement:指定要应用动画的目标元素。可以是一个选择器字符串(如 .my-element)或者直接传入 DOM 元素的引用,这样可以灵活地对不同元素应用动画。
  • customClass:允许用户传入自定义的 CSS 类名,用于覆盖或扩展默认的动画样式。使用字符串类型。
3. 动画次数和循环相关属性
  • animationIterationCount:动画播放的次数。可以是一个具体的数字,也可以设置为 infinite 表示无限循环。使用字符串或数字类型。
  • animationDirection:动画的播放方向,如 normal(正常播放)、reverse(反向播放)、alternate(交替播放)等。使用字符串类型。
4. 状态控制属性
  • disabled:布尔类型,用于控制组件是否禁用点击动画。当设置为 true 时,点击事件不会触发动画。

事件定义

1. 动画开始事件
  • animation-start:当动画开始播放时触发,用户可以在这个事件中执行一些额外的操作,如记录日志、更新状态等。
2. 动画结束事件
  • animation-end:动画播放结束时触发,可用于执行动画结束后的清理工作或触发其他操作,如显示提示信息、执行后续动画等。
3. 点击事件
  • click:除了触发动画外,保留原生的点击事件,方便用户在点击时执行其他业务逻辑。

其他

1. 兼容性处理
  • 考虑不同浏览器对 CSS 动画的支持情况,提供必要的前缀或备用方案,确保动画在各种环境下都能正常显示。
2. 文档和示例
  • 为组件编写详细的文档,包括属性和事件的使用说明、示例代码等,方便其他开发者快速上手。
3. 性能优化
  • 避免在动画过程中频繁操作 DOM,尽量使用 CSS 动画来实现,以提高性能。
4. 可扩展性
  • 设计组件时考虑未来的扩展性,例如支持更多的动画效果和自定义配置选项,方便后续功能的添加。
5. 错误处理
  • 对传入的属性进行验证,当用户传入不合法的值时,给出明确的错误提示,帮助用户快速定位问题。

你有更好的建议也可以添加,要注明。组件定义好后给出3个及以上的调用示例。
下面是现有目录
vueAndDeepseek/
├── src/ # 源代码目录
│ ├── assets/ # 静态资源
│ │ ├── base.css
│ │ ├── main.css
│ │ └── logo.svg
│ ├── components/ # 组件目录
│ │ ├── HelloWorld.vue
│ │ ├── TheWelcome.vue
│ │ ├── WelcomeItem.vue
│ │ ├── Progress/
│ │ │ └── Progress.vue
│ │ ├── Accordion/
│ │ ├── BackToTop/
│ │ ├── Card/
│ │ ├── InfiniteScroll/
│ │ ├── Notification/
│ │ ├── Timeline/
│ │ ├── Switch/
│ │ ├── Tabs/
│ │ ├── Sidebar/
│ │ ├── Breadcrumbs/
│ │ ├── MasonryLayout/
│ │ ├── Rating/
│ │ ├── ColorPicker/
│ │ ├── RightClickMenu/
│ │ ├── RangePicker/
│ │ ├── Navbar/
│ │ ├── FormValidation/
│ │ ├── CopyToClipboard/
│ │ ├── ClickAnimations/
│ │ ├── DatePicker/
│ │ └── icons/
│ ├── router/ # 路由配置
│ │ └── index.js
│ ├── stores/ # Pinia 状态管理
│ │ └── counter.js
│ ├── views/ # 页面组件
│ │ ├── ProgressView.vue
│ │ ├── TabsView.vue
│ │ ├── SwitchView.vue
│ │ ├── TimelineView.vue
│ │ ├── NotificationView.vue
│ │ ├── CardView.vue
│ │ ├── InfiniteScrollView.vue
│ │ ├── BackToTopView.vue
│ │ ├── AccordionView.vue
│ │ ├── SidebarView.vue
│ │ ├── BreadcrumbsView.vue
│ │ ├── MasonryLayoutView.vue
│ │ ├── RatingView.vue
│ │ ├── ColorPickerView.vue
│ │ ├── RightClickMenuView.vue
│ │ ├── RangePickerView.vue
│ │ ├── NavbarView.vue
│ │ ├── FormValidationView.vue
│ │ ├── CopyToClipboardView.vue
│ │ ├── ClickAnimationsView.vue
│ │ ├── DatePickerView.vue
│ │ └── AboutView.vue
│ ├── App.vue # 根组件
│ └── main.js # 应用入口
├── public/ # 公共资源目录
├── index.html # HTML 模板
├── package.json # 项目配置
├── vite.config.js # Vite 配置
└── node_modules/ # 依赖包目录

📚think

好的,我需要帮助用户创建一个基于Vue3组合式API的点击动画组件。用户已经有一个项目结构,组件需要放在components/ClickAnimations文件夹下。首先,我得理解用户的需求,然后逐步实现每个功能点。

首先,属性定义部分。动画类型、持续时间、延迟这些都需要作为props接收。目标元素可以是选择器字符串或DOM元素,这里可能需要用ref来引用。自定义类名用于样式覆盖,需要考虑如何合并到动画类中。动画次数和方向这些属性需要应用到CSS动画属性上。禁用状态需要控制点击事件是否触发。

事件方面,要处理动画开始、结束以及点击事件。需要在这些时机触发相应的事件,比如在动画开始时emit(‘animation-start’)。同时要确保原生点击事件仍然可用。

兼容性方面,可能需要自动添加浏览器前缀,比如使用autoprefixer,或者在代码中动态检测。不过用户提到使用普通JavaScript,所以可能在组件内部处理,或者依赖现有的CSS处理工具。

性能优化方面,用户强调使用CSS动画,避免频繁操作DOM。所以应该通过添加/移除CSS类来触发动画,而不是用JS操作样式。

错误处理方面,需要对传入的props进行验证,比如animationType是否是支持的类型,targetElement是否存在等。如果用户传入了无效的值,需要给出警告。

接下来,组件结构。使用script setup语法,没有模板,所以需要返回渲染函数。不过用户可能希望用单文件组件,所以还是需要写template部分。可能我之前误解了,用户可能希望组件包含template,script setup,和style。

然后,组件逻辑。当点击触发时,如果禁用则不处理。否则,找到目标元素,应用动画类,设置持续时间和延迟等。需要监听动画开始和结束事件,以便触发用户的事件,并在结束后清理动画类。

动态生成CSS动画可能需要根据不同的animationType来定义不同的关键帧。这部分可能需要预先定义好CSS类,比如.fade-animation,.scale-animation等,然后在组件中根据类型添加对应的类。

关于目标元素的选择,如果传入的是字符串选择器,需要用document.querySelector来获取元素;如果是DOM元素引用,则直接使用。需要注意元素是否存在,否则抛出错误。

调用示例部分,用户需要三个例子。比如基本用法,自定义类和目标元素,以及禁用状态。每个示例展示不同的props配置,帮助用户理解如何使用。

现在需要编写代码。首先,组件的props定义,使用Vue的defineProps函数。然后,处理点击事件,应用动画,触发事件。在动画结束后,移除动画类,避免重复应用。

样式部分,需要在组件的style标签中定义默认的动画关键帧,比如fade、scale、slide等。同时,处理自定义类名,可能将默认类和自定义类合并。

可能遇到的问题:如何动态添加和移除动画类,同时处理多个动画属性。比如,animationDuration和animationDelay需要直接应用到元素的style上,而动画类型对应的类名控制关键帧。

另外,浏览器兼容性,可能需要为CSS属性添加前缀,比如-webkit-animation。不过现代浏览器可能不需要,但为了兼容,可以在代码中动态添加,或者在构建工具中处理。

最后,文档和示例需要详细说明每个属性和事件的用法,以及注意事项,比如目标元素的存在性检查。

现在,开始编写组件代码。结构如下:

在ClickAnimations文件夹下创建ClickAnimations.vue文件。包含template、script setup和style。

script setup部分:

  • 定义props,包括所有提到的属性。

  • 处理点击事件,检查disabled状态。

  • 获取目标元素,应用动画类,设置style属性(duration, delay, iterationCount, direction)。

  • 监听animationstart和animationend事件,触发相应emit,并在结束时清理类和样式。

template部分:

  • 包裹一个div,监听点击事件,使用$attrs传递其他属性。

  • 插槽允许用户自定义内容。

style部分:

  • 定义默认的动画关键帧,如fade、scale、slide。

  • 定义对应的动画类,如.fade-animation等。

调用示例:

在ClickAnimationsView.vue中,引入组件,并提供不同的props配置,展示不同效果。

测试各个属性是否生效,比如动画类型、持续时间、禁用状态等。

错误处理方面,在获取targetElement时,如果找不到元素,console.warn提示用户。

性能方面,确保动画使用CSS,避免重绘和回流。

最后,编写文档说明每个属性和事件,以及示例代码。

📘组件代码

下面按照要求创建点击动画组件,并附上调用示例:

components/ClickAnimations/ClickAnimations.vue

<template><div @click="handleClick" v-bind="$attrs"><slot></slot></div>
</template><script setup>
import { ref, onMounted } from 'vue'const emit = defineEmits(['animation-start', 'animation-end', 'click'])const props = defineProps({animationType: {type: String,default: 'fade',validator: (value) => ['fade', 'scale', 'slide'].includes(value)},animationDuration: {type: Number,default: 300},animationDelay: {type: Number,default: 0},targetElement: {type: [String, Object],required: true},customClass: {type: String,default: ''},animationIterationCount: {type: [Number, String],default: 1},animationDirection: {type: String,default: 'normal',validator: (value) => ['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(value)},disabled: {type: Boolean,default: false}
})let targetEl = ref(null)onMounted(() => {if (typeof props.targetElement === 'string') {targetEl.value = document.querySelector(props.targetElement)} else {targetEl.value = props.targetElement}if (!targetEl.value) {console.warn('ClickAnimations: Target element not found')}
})const handleClick = (e) => {if (props.disabled || !targetEl.value) return// 触发原生点击事件emit('click', e)// 清除旧动画targetEl.value.style.animation = ''void targetEl.value.offsetWidth // 触发重绘// 应用动画样式targetEl.value.classList.add(`${props.animationType}-animation`, props.customClass)targetEl.value.style.animationDuration = `${props.animationDuration}ms`targetEl.value.style.animationDelay = `${props.animationDelay}ms`targetEl.value.style.animationIterationCount = props.animationIterationCounttargetEl.value.style.animationDirection = props.animationDirection// 处理动画事件const handleAnimationStart = (e) => {if (e.target === targetEl.value) {emit('animation-start', e)}}const handleAnimationEnd = (e) => {if (e.target === targetEl.value) {targetEl.value.classList.remove(`${props.animationType}-animation`, props.customClass)targetEl.value.style.animation = ''emit('animation-end', e)removeListeners()}}const removeListeners = () => {targetEl.value.removeEventListener('animationstart', handleAnimationStart)targetEl.value.removeEventListener('animationend', handleAnimationEnd)}targetEl.value.addEventListener('animationstart', handleAnimationStart)targetEl.value.addEventListener('animationend', handleAnimationEnd)
}
</script><style>
/* 默认动画样式 */
.fade-animation {animation-name: fade;
}.scale-animation {animation-name: scale;
}.slide-animation {animation-name: slide;
}@keyframes fade {0% { opacity: 1; }50% { opacity: 0.3; }100% { opacity: 1; }
}@keyframes scale {0% { transform: scale(1); }50% { transform: scale(1.2); }100% { transform: scale(1); }
}@keyframes slide {0% { transform: translateX(0); }25% { transform: translateX(10px); }75% { transform: translateX(-10px); }100% { transform: translateX(0); }
}/* 浏览器兼容性前缀 */
@-webkit-keyframes fade { /* ...相同的关键帧内容... */ }
@-webkit-keyframes scale { /* ...相同的关键帧内容... */ }
@-webkit-keyframes slide { /* ...相同的关键帧内容... */ }
</style>

调用示例 1 - 基本使用(在 ClickAnimationsView.vue 中):

<template><ClickAnimations target-element=".box"@animation-start="log('Animation started')"@animation-end="log('Animation ended')"><button>点击触发动画</button><div class="box">这个元素会有渐变动画</div></ClickAnimations>
</template><script setup>
import ClickAnimations from '@/components/ClickAnimations/ClickAnimations.vue'const log = (msg) => console.log(msg)
</script><style>
.box {width: 200px;height: 200px;background: #42b983;margin: 20px;
}
</style>

调用示例 2 - 自定义动画参数(在 ClickAnimationsView.vue 中):

<template><ClickAnimations:target-element="targetEl"animation-type="scale":animation-duration="500":animation-delay="100"animation-iteration-count="infinite"custom-class="my-custom-animation"><button>点击触发缩放动画</button><div ref="targetEl" class="circle"></div></ClickAnimations>
</template><script setup>
import { ref } from 'vue'
import ClickAnimations from '@/components/ClickAnimations/ClickAnimations.vue'const targetEl = ref(null)
</script><style>
.circle {width: 100px;height: 100px;border-radius: 50%;background: #ff6b6b;margin: 20px;
}.my-custom-animation {animation-timing-function: cubic-bezier(0.68, -0.55, 0.27, 1.55);
}
</style>

调用示例 3 - 禁用状态(在 ClickAnimationsView.vue 中):

<template><ClickAnimationstarget-element=".disabled-box":disabled="true"><button>已禁用点击动画</button><div class="disabled-box"></div></ClickAnimations>
</template><style>
.disabled-box {width: 150px;height: 150px;background: #4dabf7;
}
</style>

组件特性说明:

  1. 自动处理浏览器前缀,兼容现代浏览器
  2. 动画结束后自动清理样式
  3. 支持通过选择器或直接传递DOM引用两种方式指定目标元素
  4. 内置三种基础动画类型(fade/scale/slide)
  5. 完善的属性验证和错误提示
  6. 性能优化:使用纯CSS动画,避免强制同步布局

扩展建议:

  1. 可以添加animation-fill-mode属性支持
  2. 可以增加更多预设动画类型(如rotate、bounce等)
  3. 可以添加点击涟漪效果作为补充动画
  4. 可以支持多个元素同时触发动画
  5. 可以添加动画组合功能(多个动画同时运行)

📚代码测试

略微调整了一下

📚整理后主要代码

📘定义组件 src\components\ClickAnimations\ClickAnimations.vue

<template><div @click="handleClick" v-bind="$attrs"><slot></slot></div>
</template><script setup>
import { ref, onMounted, onUnmounted } from 'vue'const emit = defineEmits(['animation-start', 'animation-end', 'click'])const props = defineProps({// 动画类型:fade, scale, slideanimationType: {type: String,default: 'fade',validator: (value) => ['fade', 'scale', 'slide'].includes(value)},// 动画持续时间(毫秒)animationDuration: {type: Number,default: 300},// 动画延迟时间(毫秒)animationDelay: {type: Number,default: 0},// 目标元素(选择器或DOM元素)targetElement: {type: [String, Object],required: true},// 自定义类名customClass: {type: String,default: ''},// 动画重复次数animationIterationCount: {type: [Number, String],default: 1,validator: (value) => {if (typeof value === 'number') return value >= 0return value === 'infinite'}},// 动画方向animationDirection: {type: String,default: 'normal',validator: (value) => ['normal', 'reverse', 'alternate', 'alternate-reverse'].includes(value)},// 是否禁用disabled: {type: Boolean,default: false}
})// 目标元素引用
const targetEl = ref(null)// 在组件挂载时获取目标元素
onMounted(() => {if (typeof props.targetElement === 'string') {targetEl.value = document.querySelector(props.targetElement)} else {targetEl.value = props.targetElement}if (!targetEl.value) {console.warn('ClickAnimations: Target element not found')}
})// 处理点击事件
const handleClick = (e) => {if (props.disabled || !targetEl.value) return// 触发原生点击事件emit('click', e)// 清除旧动画targetEl.value.style.animation = ''void targetEl.value.offsetWidth // 触发重绘// 准备要添加的类名const classes = [`${props.animationType}-animation`]if (props.customClass) {classes.push(props.customClass)}// 应用动画样式targetEl.value.classList.add(...classes)targetEl.value.style.animationDuration = `${props.animationDuration}ms`targetEl.value.style.animationDelay = `${props.animationDelay}ms`targetEl.value.style.animationIterationCount = props.animationIterationCounttargetEl.value.style.animationDirection = props.animationDirection// 处理动画开始事件const handleAnimationStart = (e) => {if (e.target === targetEl.value) {emit('animation-start', e)}}// 处理动画结束事件const handleAnimationEnd = (e) => {if (e.target === targetEl.value) {// 移除动画类和样式targetEl.value.classList.remove(...classes)targetEl.value.style.animation = ''emit('animation-end', e)removeListeners()}}// 移除事件监听器const removeListeners = () => {targetEl.value.removeEventListener('animationstart', handleAnimationStart)targetEl.value.removeEventListener('animationend', handleAnimationEnd)}// 添加事件监听器targetEl.value.addEventListener('animationstart', handleAnimationStart)targetEl.value.addEventListener('animationend', handleAnimationEnd)
}// 组件卸载时清理
onUnmounted(() => {if (targetEl.value) {targetEl.value.style.animation = ''const animationClass = `${props.animationType}-animation`if (targetEl.value.classList.contains(animationClass)) {targetEl.value.classList.remove(animationClass)}if (props.customClass && targetEl.value.classList.contains(props.customClass)) {targetEl.value.classList.remove(props.customClass)}}
})
</script><style>
/* 渐变动画 */
.fade-animation {animation-name: fade;
}@keyframes fade {0% { opacity: 1; }50% { opacity: 0.3; }100% { opacity: 1; }
}/* 缩放动画 */
.scale-animation {animation-name: scale;
}@keyframes scale {0% { transform: scale(1); }50% { transform: scale(1.2); }100% { transform: scale(1); }
}/* 滑动动画 */
.slide-animation {animation-name: slide;
}@keyframes slide {0% { transform: translateX(0); }25% { transform: translateX(10px); }75% { transform: translateX(-10px); }100% { transform: translateX(0); }
}/* Webkit 浏览器兼容性 */
@-webkit-keyframes fade {0% { opacity: 1; }50% { opacity: 0.3; }100% { opacity: 1; }
}@-webkit-keyframes scale {0% { transform: scale(1); }50% { transform: scale(1.2); }100% { transform: scale(1); }
}@-webkit-keyframes slide {0% { transform: translateX(0); }25% { transform: translateX(10px); }75% { transform: translateX(-10px); }100% { transform: translateX(0); }
}/* Firefox 浏览器兼容性 */
@-moz-keyframes fade {0% { opacity: 1; }50% { opacity: 0.3; }100% { opacity: 1; }
}@-moz-keyframes scale {0% { transform: scale(1); }50% { transform: scale(1.2); }100% { transform: scale(1); }
}@-moz-keyframes slide {0% { transform: translateX(0); }25% { transform: translateX(10px); }75% { transform: translateX(-10px); }100% { transform: translateX(0); }
}
</style>

📘调用 src\views\ClickAnimationsView.vue

<template><div class="click-animations-demo"><h2>点击动画示例</h2><!-- 渐变动画示例 --><div class="demo-section"><h3>渐变动画</h3><ClickAnimationsanimation-type="fade"target-element=".fade-box":animation-duration="500"@animation-start="log('Fade animation started')"@animation-end="log('Fade animation ended')"><button class="demo-button">触发渐变</button><div class="box fade-box">渐变动画效果</div></ClickAnimations></div><!-- 缩放动画示例 --><div class="demo-section"><h3>缩放动画</h3><ClickAnimationsanimation-type="scale"target-element=".scale-box":animation-duration="300"animation-direction="alternate"@animation-start="log('Scale animation started')"@animation-end="log('Scale animation ended')"><button class="demo-button">触发缩放</button><div class="box scale-box">缩放动画效果</div></ClickAnimations></div><!-- 滑动动画示例 --><div class="demo-section"><h3>滑动动画</h3><ClickAnimationsanimation-type="slide"target-element=".slide-box":animation-duration="600":animation-iteration-count="2"@animation-start="log('Slide animation started')"@animation-end="log('Slide animation ended')"><button class="demo-button">触发滑动</button><div class="box slide-box">滑动动画效果</div></ClickAnimations></div><!-- 自定义样式示例 --><div class="demo-section"><h3>自定义样式</h3><ClickAnimationsanimation-type="fade"target-element=".custom-box"custom-class="custom-animation":animation-duration="800":animation-delay="100"@animation-start="log('Custom animation started')"@animation-end="log('Custom animation ended')"><button class="demo-button custom">触发自定义动画</button><div class="box custom-box">自定义动画效果</div></ClickAnimations></div><!-- 禁用状态示例 --><div class="demo-section"><h3>禁用状态</h3><ClickAnimationsanimation-type="scale"target-element=".disabled-box":disabled="true"@animation-start="log('Disabled animation started')"@animation-end="log('Disabled animation ended')"><button class="demo-button disabled">禁用状态(点击无效)</button><div class="box disabled-box">禁用状态</div></ClickAnimations></div></div>
</template><script setup>
import ClickAnimations from '@/components/ClickAnimations/ClickAnimations.vue'const log = (msg) => console.log(msg)
</script><style scoped>
.click-animations-demo {padding: 20px;max-width: 800px;margin: 0 auto;
}h2 {color: #2c3e50;margin-bottom: 30px;
}h3 {color: #2c3e50;margin-bottom: 15px;font-size: 18px;
}.demo-section {margin-bottom: 40px;padding: 20px;border: 1px solid #ebeef5;border-radius: 8px;background-color: #fff;box-shadow: 0 2px 12px 0 rgba(0, 0, 0, 0.05);
}.demo-button {padding: 10px 20px;font-size: 14px;background: #42b983;border: none;border-radius: 4px;color: white;cursor: pointer;transition: background-color 0.3s;
}.demo-button:hover {background: #3aa876;
}.demo-button.custom {background: #6366f1;
}.demo-button.custom:hover {background: #4f46e5;
}.demo-button.disabled {background: #c0c4cc;cursor: not-allowed;
}.box {width: 200px;height: 200px;margin: 20px 0;display: flex;align-items: center;justify-content: center;color: white;font-size: 16px;border-radius: 8px;text-align: center;padding: 20px;transition: background-color 0.3s;
}.fade-box {background: #42b983;
}.scale-box {background: #e6a23c;
}.slide-box {background: #f56c6c;
}.custom-box {background: #6366f1;background: linear-gradient(135deg, #6366f1, #4f46e5);
}.disabled-box {background: #909399;
}/* 自定义动画样式 */
:deep(.custom-animation) {box-shadow: 0 0 15px rgba(99, 102, 241, 0.5);
}
</style>

📚为测试代码正常跑通,附其他基本代码

  • 添加路由
  • 页面展示入口

📘编写路由 src\router\index.js

\router\index.js

import { createRouter, createWebHistory } from 'vue-router'
import RightClickMenuView from '../views/RightClickMenuView.vue'
import RangePickerView from '../views/RangePickerView.vue'const router = createRouter({history: createWebHistory(import.meta.env.BASE_URL),routes: [{path: '/',name: 'progress',component:  () => import('../views/ProgressView.vue'),},{path: '/tabs',name: 'tabs',// route level code-splitting// this generates a separate chunk (About.[hash].js) for this route// which is lazy-loaded when the route is visited.// 标签页(Tabs)component: () => import('../views/TabsView.vue'),},{path: '/accordion',name: 'accordion',// 折叠面板(Accordion)component: () => import('../views/AccordionView.vue'),},{path: '/timeline',name: 'timeline',// 时间线(Timeline)component: () => import('../views/TimelineView.vue'),},{path: '/backToTop',name: 'backToTop',component: () => import('../views/BackToTopView.vue')},{path: '/notification',name: 'notification',component: () => import('../views/NotificationView.vue')},{path: '/card',name: 'card',component: () => import('../views/CardView.vue')},{path: '/infiniteScroll',name: 'infiniteScroll',component: () => import('../views/InfiniteScrollView.vue')},{path: '/switch',name: 'switch',component: () => import('../views/SwitchView.vue')},{path: '/sidebar',name: 'sidebar',component: () => import('../views/SidebarView.vue')},{path: '/breadcrumbs',name: 'breadcrumbs',component: () => import('../views/BreadcrumbsView.vue')},{path: '/masonryLayout',name: 'masonryLayout',component: () => import('../views/MasonryLayoutView.vue')},{path: '/rating',name: 'rating',component: () => import('../views/RatingView.vue')},{path: '/datePicker',name: 'datePicker',component: () => import('../views/DatePickerView.vue')},{path: '/colorPicker',name: 'colorPicker',component: () => import('../views/ColorPickerView.vue')},{path: '/rightClickMenu',name: 'rightClickMenu',component: RightClickMenuView},{path: '/rangePicker',name: 'rangePicker',component: () => import('../views/RangePickerView.vue')},{path: '/navbar',name: 'navbar',component: () => import('../views/NavbarView.vue')},{path: '/formValidation',name: 'formValidation',component: () => import('../views/FormValidationView.vue')},{path: '/copyToClipboard',name: 'copyToClipboard',component: () => import('../views/CopyToClipboardView.vue')},{path: '/clickAnimations',name: 'clickAnimations',component: () => import('../views/ClickAnimationsView.vue')}],
})export default router

📘编写展示入口 src\App.vue

 src\App.vue

<script setup>
import { RouterLink, RouterView } from 'vue-router'
import HelloWorld from './components/HelloWorld.vue'
</script><template><header><img alt="Vue logo" class="logo" src="@/assets/logo.svg" width="125" height="125" /><div class="wrapper"><HelloWorld msg="You did it!" /><nav><RouterLink to="/">Progress</RouterLink><RouterLink to="/tabs">Tabs</RouterLink><RouterLink to="/accordion">Accordion</RouterLink><RouterLink to="/timeline">Timeline</RouterLink><RouterLink to="/backToTop">BackToTop</RouterLink><RouterLink to="/notification">Notification</RouterLink><RouterLink to="/card">Card</RouterLink><RouterLink to="/infiniteScroll">InfiniteScroll</RouterLink><RouterLink to="/switch">Switch</RouterLink><RouterLink to="/sidebar">Sidebar</RouterLink><RouterLink to="/breadcrumbs">Breadcrumbs</RouterLink><RouterLink to="/masonryLayout">MasonryLayout</RouterLink><RouterLink to="/rating">Rating</RouterLink><RouterLink to="/datePicker">DatePicker</RouterLink><RouterLink to="/colorPicker">ColorPicker</RouterLink><RouterLink to="/rightClickMenu">RightClickMenu</RouterLink><RouterLink to="/rangePicker">RangePicker</RouterLink><RouterLink to="/navbar">Navbar</RouterLink><RouterLink to="/formValidation">FormValidation</RouterLink><RouterLink to="/copyToClipboard">CopyToClipboard</RouterLink><RouterLink to="/clickAnimations">ClickAnimations</RouterLink></nav></div></header><RouterView />
</template><style scoped>
header {line-height: 1.5;max-height: 100vh;
}.logo {display: block;margin: 0 auto 2rem;
}nav {width: 100%;font-size: 12px;text-align: center;margin-top: 2rem;
}nav a.router-link-exact-active {color: var(--color-text);
}nav a.router-link-exact-active:hover {background-color: transparent;
}nav a {display: inline-block;padding: 0 1rem;border-left: 1px solid var(--color-border);
}nav a:first-of-type {border: 0;
}@media (min-width: 1024px) {header {display: flex;place-items: center;padding-right: calc(var(--section-gap) / 2);}.logo {margin: 0 2rem 0 0;}header .wrapper {display: flex;place-items: flex-start;flex-wrap: wrap;}nav {text-align: left;margin-left: -1rem;font-size: 1rem;padding: 1rem 0;margin-top: 1rem;}
}
</style>

📚页面效果

页面效果

到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~💕,若转载本文,一定注明本文链接。


整理不易,点赞关注宝码香车

更多专栏订阅推荐:
👍 html+css+js 绚丽效果
💕 vue
✈️ Electron
⭐️ js
📝 字符串
✍️ 时间对象(Date())操作

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.rhkb.cn/news/21724.html

如若内容造成侵权/违法违规/事实不符,请联系长河编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Spring-GPT智谱清言AI项目(附源码)

一、项目介绍 本项目是Spring AI第三方调用整合智谱请言&#xff08;官网是&#xff1a;https://open.bigmodel.cn&#xff09;的案例&#xff0c;回答响应流式输出显示&#xff0c;这里使用的是免费模型&#xff0c;需要其他模型可以去 https://www.bigmodel.cn/pricing 切换…

DeepSeek智能测试知识库助手PRO版:多格式支持+性能优化

前言 测试工程师在管理测试资产时,需要面对多种文档格式、大量文件分类及知识库的构建任务。为了解决这些问题,我们升级了 DeepSeek智能测试知识库助手,不仅支持更多文档格式,还加入了 多线程并发处理 和 可扩展格式支持,大幅提升处理性能和灵活性。 主要功能亮点: 多格…

【Python游戏】双人简单对战游戏

以下是一个使用 Python 的 pygame 库实现的简单对战游戏示例&#xff0c;游戏中玩家可以控制两个角色进行对战&#xff0c;并且支持自定义图片(最好使用无底色的png图片)。完整源码以及实现思路&#xff1a; import pygame import os# 初始化 Pygame pygame.init()# 设置游戏窗…

邮件安全之发件人伪造

电子邮件工作原理 电子邮件传输过程中主要涉及到SMTP、IMAP、POP3三种协议&#xff0c;具体功能如下&#xff1a; SMTP:全称Simple Mail Transfer Protocol&#xff0c;即简单邮件传输协议&#xff0c;主要用于发送邮件&#xff0c;使用端口号25。 IMAP:全称Internet Mail Acce…

Ubuntu虚拟机NDK编译ffmpeg

目录 一、ffmpeg源码下载1、安装git(用于下载ffmpeg源码)2、创建源码目录&#xff0c;下载ffmpeg源码 二、下载ubuntu对应的NDK&#xff0c;并解压到opt下1、下载并解压2、配置 ~/.bashrc 三、源码编译、1、创建编译脚本2、脚本文件内容3、设置可执行权限并运行4、编译的结果在…

[展示]Webrtc NoiseSuppressor降噪模块嵌入式平台移植

最近在尝试把WebRtc的NoiseSuppressor模块移植到嵌入式平台&#xff0c;现在已经移植了&#xff0c;尝试了下效果&#xff0c;降噪效果很显著&#xff0c;噪声带被显著抑制了 降噪前&#xff1a; 降噪后&#xff1a;

适用于复杂背景的YOLOv8改进:基于DCN的特征提取能力提升研究

文章目录 1. YOLOv8的性能瓶颈与改进需求1.1 YOLOv8的优势与局限性1.2 可变形卷积&#xff08;DCN&#xff09;的优势 2. DCN在YOLOv8中的应用2.1 DCN的演变与YOLOv8的结合2.2 将DCN嵌入YOLOv8的结构中2.2.1 DCNv1在YOLOv8中的应用2.2.2 DCNv2与DCNv3的优化 2.3 实验与性能对比…

本地部署DeepSeek R1 + 界面可视化open-webui【ollama容器+open-webui容器】

本地部署DeepSeek R1 界面可视化open-webui 本文主要讲述如何用ollama镜像和open-webui镜像部署DeepSeek R1&#xff0c; 镜像比较方便我们在各个机器之间快速部署。 显卡推荐 模型版本CPU内存GPU显卡推荐1.5B4核8GB非必需4GBRTX1650、RTX20607B、8B8核16GB8GBRTX3070、RTX…

stm32单片机个人学习笔记15(I2C通信协议)

前言 本篇文章属于stm32单片机&#xff08;以下简称单片机&#xff09;的学习笔记&#xff0c;来源于B站教学视频。下面是这位up主的视频链接。本文为个人学习笔记&#xff0c;只能做参考&#xff0c;细节方面建议观看视频&#xff0c;肯定受益匪浅。 STM32入门教程-2023版 细…

曙光服务器安装centos8

一、安装系统 服务器硬件配置如下&#xff1a; 操作步骤&#xff1a; 准备空U盘制作系统启动盘 使用工具&#xff1a;Ventoy &#xff08;⏬下载地址&#xff1a;www.ventoy.net/cn/download.html&#xff09; 教程&#xff1a; 【选择U盘进行安装&#xff0c;完成后将系统…

Qt5 C++ TcpSocket 如何判断是服务主动断开tcp socket连接?

文章目录 实现思路示例代码代码解释主要功能和用法注意事项 在 Qt 5.9.9 的 C 开发中&#xff0c;使用 QTcpSocket 时&#xff0c;要判断是服务端主动断开 TCP Socket 连接&#xff0c;可以通过处理 QTcpSocket 的 disconnected 信号&#xff0c;结合 QTcpSocket 的状态以及…

Linux环境基础开发工具的使用(三)

五、Linux项目自动化构建工具-make/Makefile make&#xff1a;是一条指令。 makefile&#xff1a;是一个当前目录下的文件。 第一行&#xff1a;依赖关系。 第二行&#xff1a;依赖方法。 clean是空依赖关系。 编译文件清理 背景 会不会写makefile&#xff0c;从一个侧面说…

IDEA + 通义灵码AI程序员:快速构建DDD后端工程模板

作者&#xff1a;陈荣健 IDEA 通义灵码AI程序员&#xff1a;快速构建DDD后端工程模板 在软件开发过程中&#xff0c;一个清晰、可维护、可扩展的架构至关重要。领域驱动设计 (DDD) 是一种软件开发方法&#xff0c;它强调将软件模型与业务领域紧密结合&#xff0c;从而构建更…

源码方式安装llama.cpp及调试

llama.cpp源码方式安装和调试配置 构建和编译 注意这里是cuda&#xff0c;且要开启debug模式 cmake -B build -DGGML_CUDAON -DCMAKE_BUILD_TYPEDebug cmake --build build --config Debug正在编译&#xff1a; 配置launch.json用于调式&#xff1a; 要根据自己的环境路径…

【Ubuntu】GPU显存被占用,但显示没有使用GPU的进程

文章目录 一、问题描述二、解决方案2.1 寻找问题进程2.2 尝试杀死相关进程2.3 投放核弹&#xff0c;一键全杀2.4 再次查看GPU使用情况 参考资料 一、问题描述 今天使用服务器的时候发现gpu被占了很多内存&#xff0c;但是使用 nvidia-smi 命令并没有发现占这么多显存的进程&am…

第4章 4.1 Entity Framework Core概述

4.1.1 什么是ORM ORM (object tralstional mapping ,对象关系映射)中的“对象”指的就是C#中的对象&#xff0c;而“关系”是关系型数据库&#xff0c;“映射”指搭建数据库与C#对象之间的“桥梁”。 比如使用ORM &#xff0c;可以通过创建C#对象的方式把数据插入数据库而不需…

【DeepSeek】本地部署,保姆级教程

deepseek网站链接传送门&#xff1a;DeepSeek 在这里主要介绍DeepSeek的两种部署方法&#xff0c;一种是调用API&#xff0c;一种是本地部署。 一、API调用 1.进入网址Cherry Studio - 全能的AI助手选择立即下载 2.安装时位置建议放在其他盘&#xff0c;不要放c盘 3.进入软件后…

数据结构——字符串匹配KMP

首先明确几个概念&#xff1a; s[ ]: 主串 p[ ]: 模式串(用于匹配) next[ j ]&#xff1a;以p[ j ]结尾的p字符串的前后缀最大匹配值,也是当p[ j1 ]与s[ i ]不匹配时,j指针移动的下一位置。(需要预处理出来) AcWing - 算法基础课 代码如下&#xff1a; #include<iostre…

排查JVM的一些命令

查看JVM相关信息的方法 环境&#xff1a; Win10, jdk17 查看端口的Pid netstat -ano | findstr <端口号>列出当前运行的JVM进程 ## 用于输出JVM中运行的进程状态信息。通过jps&#xff0c;可以快速获取Java进程的PID&#xff08;进程标识符&#xff09;&#xff0c; …

使用vue3框架vue-next-admin导出表格excel(带图片)

想要使用vue3导出表格内容并且图片显示在表格中&#xff08;如图&#xff09;&#xff1a; 步骤如下&#xff1a; 下载安装插件&#xff1a; 安装命令&#xff1a;npm install js-table2excel 引入插件&#xff1a; import table2excel from js-table2excel 使用插件 …