前言:哈喽,大家好,今天给大家分享一篇文章!并提供具体代码帮助大家深入理解,彻底掌握!创作不易,如果能帮助到大家或者给大家一些灵感和启发,欢迎收藏+关注哦
️✍️️️️⚠️⬇️·正文开始
⬇️·✅❓ 0️⃣1️⃣2️⃣3️⃣4️⃣5️⃣6️⃣7️⃣8️⃣9️⃣*️⃣#️⃣
模型优化同样面临挑战。随着模型规模的增大,模型的复杂度也随之增加,这给模型的优化带来了困难。在模型训练过程中,可能会出现梯度消失、梯度爆炸等问题,导致模型无法收敛或训练不稳定。模型的可解释性也是一个难题。大语言模型通常是一个复杂的黑盒模型,难以理解其决策过程和输出结果的依据。在医疗、金融等对决策可靠性要求较高的领域,模型的不可解释性限制了其应用。在医疗诊断中,医生需要了解模型给出诊断建议的依据,以便做出准确的判断。但目前的大语言模型很难满足这一要求,这使得其在医疗领域的应用受到了一定的限制。
已经创建好了一个基于Vue3的组合式API的项目(Composition API),并能正常运行起来,请帮我用 Vue3的组合式API(Composition API) 生成一个 滚动动画(Scroll Animations) 的功能组件,所有代码都保存在components/ScrollAnimations 下的文件夹中。功能组件的script标签中只有setup属性,使用普通 JavaScript 实现,不使用TypeScript。
功能要有,如下属性:
animationType
String
fadeIn
(淡入)、slideInLeft
(从左侧滑入)、slideInRight
(从右侧滑入)等,用户可以根据需要选择不同的动画效果。animationDuration
Number
1
秒,用于控制动画播放的快慢。animationDelay
Number
0
秒,可用于实现动画的顺序播放效果。triggerOffset
Number
0.5
,即元素进入视口一半时触发。isAnimated
Boolean
false
,可以通过修改该属性来重置或强制播放动画。once
Boolean
true
,如果设置为 false
,当元素离开视口再进入时,动画会再次播放。targetSelector
String
animation-start
animation-end
来封装组件的样式,避免样式冲突。同时,可以将动画相关的 CSS 动画关键帧定义在组件内部,方便维护和复用。IntersectionObserver
来监听元素是否进入视口,避免使用 scroll
事件,以提高性能,特别是在处理大量元素时。requestAnimationFrame
来优化动画的渲染性能。IntersectionObserver
的兼容性,可使用 @keyframes
动画和 IntersectionObserver
的 polyfill 来确保在旧浏览器中也能正常工作。你有更好的建议也可以添加,要注明。组件定义好后给出5个及以上的调用示例。
下面是现有目录
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/
│ │ ├── ThumbnailList/
│ │ ├── KeyboardShortcuts/
│ │ ├── CommentSystem/
│ │ ├── QRCode/
│ │ ├── RadioButton/
│ │ ├── Slider/
│ │ ├── ScrollAnimations/
│ │ ├── 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
│ │ ├── ThumbnailListView.vue
│ │ ├── KeyboardShortcutsView.vue
│ │ ├── CommentSystemView.vue
│ │ ├── QRCodeView.vue
│ │ ├── RadioButtonView.vue
│ │ ├── SliderView.vue
│ │ ├── ScrollAnimationsView.vue
│ │ ├── DatePickerView.vue
│ │ └── AboutView.vue
│ ├── App.vue # 根组件
│ └── main.js # 应用入口
├── public/ # 公共资源目录
├── index.html # HTML 模板
├── package.json # 项目配置
├── vite.config.js # Vite 配置
└── node_modules/ # 依赖包目录
根据你的需求,我为你创建了一个滚动动画组件,以下是实现代码:
components/ScrollAnimations/ScrollAnimations.vue
<script setup>
import { ref, onMounted, watch, computed } from 'vue';
const props = defineProps({
animationType: {
type: String,
default: 'fadeIn'
},
animationDuration: {
type: Number,
default: 1
},
animationDelay: {
type: Number,
default: 0
},
triggerOffset: {
type: Number,
default: 0.5,
validator: value => value >= 0 && value <= 1
},
isAnimated: {
type: Boolean,
default: false
},
once: {
type: Boolean,
default: true
},
targetSelector: {
type: String,
default: null
}
});
const emit = defineEmits(['animation-start', 'animation-end', 'update:isAnimated']);
const element = ref(null);
const observer = ref(null);
const internalIsAnimated = ref(props.isAnimated);
const animationStyle = computed(() => ({
animationDuration: `${props.animationDuration}s`,
animationDelay: `${props.animationDelay}s`,
animationFillMode: 'both'
}));
const handleAnimationStart = () => {
emit('animation-start');
emit('update:isAnimated', true);
};
const handleAnimationEnd = () => {
emit('animation-end');
if (props.once && observer.value) {
observer.value.disconnect();
}
};
const initObserver = () => {
const options = {
threshold: props.triggerOffset,
rootMargin: '0px'
};
observer.value = new IntersectionObserver((entries) => {
entries.forEach(entry => {
if (entry.isIntersecting && !internalIsAnimated.value) {
internalIsAnimated.value = true;
handleAnimationStart();
}
});
}, options);
const target = props.targetSelector ?
element.value.querySelector(props.targetSelector) :
element.value;
if (target) {
observer.value.observe(target);
}
};
watch(() => props.isAnimated, (newVal) => {
internalIsAnimated.value = newVal;
if (!newVal) initObserver();
});
onMounted(() => {
initObserver();
});
script>
<template>
<div
ref="element"
:class="['scroll-animation', `animate-${animationType}`]"
:style="animationStyle"
@animationend="handleAnimationEnd"
>
<slot />
div>
template>
<style scoped>
.scroll-animation {
opacity: 0;
}
.animate-fadeIn {
animation-name: fadeIn;
}
.animate-slideInLeft {
animation-name: slideInLeft;
}
.animate-slideInRight {
animation-name: slideInRight;
}
@keyframes fadeIn {
from {
opacity: 0;
}
to {
opacity: 1;
}
}
@keyframes slideInLeft {
from {
opacity: 0;
transform: translateX(-100%);
}
to {
opacity: 1;
transform: translateX(0);
}
}
@keyframes slideInRight {
from {
opacity: 0;
transform: translateX(100%);
}
to {
opacity: 1;
transform: translateX(0);
}
}
style>
以下是5个使用示例:
<ScrollAnimations animation-type="fadeIn">
<div class="content">默认淡入效果div>
ScrollAnimations>
<ScrollAnimations
animation-type="slideInLeft"
:animation-duration="1.5"
:animation-delay="0.3"
:trigger-offset="0.2"
>
<div class="card">快速触发的滑动卡片div>
ScrollAnimations>
<ScrollAnimations
target-selector=".item"
:once="false"
animation-type="slideInRight"
>
<div v-for="i in 5" :key="i" class="item">
项目 {{ i }} - 重复触发的动画
div>
ScrollAnimations>
<template>
<ScrollAnimations
v-model:is-animated="isAnimated"
animation-type="fadeIn"
>
<div>可重置的动画内容div>
ScrollAnimations>
<button @click="isAnimated = false">重置动画button>
template>
<script setup>
import { ref } from 'vue';
const isAnimated = ref(false);
script>
<template>
<ScrollAnimations
animation-type="slideInLeft"
@animation-start="logStart"
@animation-end="logEnd"
>
<div class="stats">统计卡片div>
ScrollAnimations>
template>
<script setup>
const logStart = () => console.log('动画开始');
const logEnd = () => console.log('动画结束');
script>
附加建议:
will-change
属性优化动画性能.scroll-animation {
will-change: transform, opacity;
}
.animate-zoomIn {
animation-name: zoomIn;
}
@keyframes zoomIn {
from {
transform: scale(0.5);
opacity: 0;
}
to {
transform: scale(1);
opacity: 1;
}
}
响应式断点支持:
可以通过添加props支持不同断点的动画配置
滚动节流优化:
虽然使用了IntersectionObserver,但对于高频更新可以添加适当的检查间隔
动画队列控制:
添加animation-timing-function
属性支持,允许自定义缓动函数
组件特点:
使用时请注意:
正常
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')
},
{
path: '/thumbnailList',
name: 'thumbnailList',
component: () => import('../views/ThumbnailListView.vue')
},
{
path: '/keyboardShortcuts',
name: 'keyboardShortcuts',
component: () => import('../views/KeyboardShortcutsView.vue')
},
{
path: '/commentSystem',
name: 'commentSystem',
component: () => import('../views/CommentSystemView.vue')
},
{
path: '/qRCode',
name: 'qRCode',
component: () => import('../views/QRCodeView.vue')
},
{
path: '/radioButton',
name: 'radioButton',
component: () => import('../views/RadioButtonView.vue')
},
{
path: '/slider',
name: 'slider',
component: () => import('../views/SliderView.vue')
},
{
path: '/scrollAnimations',
name: 'scrollAnimations',
component: () => import('../views/ScrollAnimationsView.vue')
}
],
})
export default router
<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="/">ProgressRouterLink>
<RouterLink to="/tabs">TabsRouterLink>
<RouterLink to="/accordion">AccordionRouterLink>
<RouterLink to="/timeline">TimelineRouterLink>
<RouterLink to="/backToTop">BackToTopRouterLink>
<RouterLink to="/notification">NotificationRouterLink>
<RouterLink to="/card">CardRouterLink>
<RouterLink to="/infiniteScroll">InfiniteScrollRouterLink>
<RouterLink to="/switch">SwitchRouterLink>
<RouterLink to="/sidebar">SidebarRouterLink>
<RouterLink to="/breadcrumbs">BreadcrumbsRouterLink>
<RouterLink to="/masonryLayout">MasonryLayoutRouterLink>
<RouterLink to="/rating">RatingRouterLink>
<RouterLink to="/datePicker">DatePickerRouterLink>
<RouterLink to="/colorPicker">ColorPickerRouterLink>
<RouterLink to="/rightClickMenu">RightClickMenuRouterLink>
<RouterLink to="/rangePicker">RangePickerRouterLink>
<RouterLink to="/navbar">NavbarRouterLink>
<RouterLink to="/formValidation">FormValidationRouterLink>
<RouterLink to="/copyToClipboard">CopyToClipboardRouterLink>
<RouterLink to="/clickAnimations">ClickAnimationsRouterLink>
<RouterLink to="/thumbnailList">ThumbnailListRouterLink>
<RouterLink to="/keyboardShortcuts">KeyboardShortcutsRouterLink>
<RouterLink to="/commentSystem">CommentSystemRouterLink>
<RouterLink to="/qRCode">QRCodeRouterLink>
<RouterLink to="/radioButton">RadioButtonRouterLink>
<RouterLink to="/slider">SliderRouterLink>
<RouterLink to="/scrollAnimations">ScrollAnimationsRouterLink>
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>
0基础3步部署自己的DeepSeek安装步骤
DeepSeek 助力 Vue 开发:打造丝滑的步骤条(Step bar)https://blog.csdn.net/qq_33650655/article/details/145560497
DeepSeek 助力 Vue 开发:打造丝滑的进度条(Progress Bar)https://blog.csdn.net/qq_33650655/article/details/145577034
自己部署 DeepSeek 助力 Vue 开发:打造丝滑的标签页(Tabs)https://blog.csdn.net/qq_33650655/article/details/145587999
自己部署 DeepSeek 助力 Vue 开发:打造丝滑的折叠面板(Accordion)https://blog.csdn.net/qq_33650655/article/details/145590404
自己部署 DeepSeek 助力 Vue 开发:打造丝滑的时间线(Timeline )https://blog.csdn.net/qq_33650655/article/details/145597372
DeepSeek 助力 Vue 开发:打造丝滑的返回顶部按钮(Back to Top)https://blog.csdn.net/qq_33650655/article/details/145615550
DeepSeek 助力 Vue 开发:打造丝滑的通知栏(Notification Bar)https://blog.csdn.net/qq_33650655/article/details/145620055
DeepSeek 助力 Vue 开发:打造丝滑的卡片(Card)https://blog.csdn.net/qq_33650655/article/details/145634564
DeepSeek 助力 Vue 开发:打造丝滑的无限滚动(Infinite Scroll)https://blog.csdn.net/qq_33650655/article/details/145638452
DeepSeek 助力 Vue 开发:打造丝滑的开关切换(Switch)https://blog.csdn.net/qq_33650655/article/details/145644151
DeepSeek 助力 Vue 开发:打造丝滑的侧边栏(Sidebar)https://blog.csdn.net/qq_33650655/article/details/145654204
DeepSeek 助力 Vue 开发:打造丝滑的面包屑导航(Breadcrumbs)https://blog.csdn.net/qq_33650655/article/details/145656895
DeepSeek 助力 Vue 开发:打造丝滑的瀑布流布局(Masonry Layout)https://blog.csdn.net/qq_33650655/article/details/145663699
DeepSeek 助力 Vue 开发:打造丝滑的评分组件(Rating)https://blog.csdn.net/qq_33650655/article/details/145664576
DeepSeek 助力 Vue 开发:打造丝滑的日期选择器(Date Picker),未使用第三方插件 https://blog.csdn.net/qq_33650655/article/details/145673279
DeepSeek 助力 Vue 开发:打造丝滑的颜色选择器(Color Picker)https://blog.csdn.net/qq_33650655/article/details/145689522
DeepSeek 助力 Vue 开发:打造丝滑的右键菜单(RightClickMenu)https://blog.csdn.net/qq_33650655/article/details/145706658
DeepSeek 助力 Vue 开发:打造丝滑的范围选择器(Range Picker)https://blog.csdn.net/qq_33650655/article/details/145713572
DeepSeek 助力 Vue 开发:打造丝滑的导航栏(Navbar)https://blog.csdn.net/qq_33650655/article/details/145732421
DeepSeek 助力 Vue 开发:打造丝滑的表单验证(Form Validation)https://blog.csdn.net/qq_33650655/article/details/145735582
DeepSeek 助力 Vue 开发:打造丝滑的复制到剪贴板(Copy to Clipboard)https://blog.csdn.net/qq_33650655/article/details/145739569
DeepSeek 助力 Vue 开发:打造丝滑的点击动画(Click Animations)https://blog.csdn.net/qq_33650655/article/details/145766184
DeepSeek 助力 Vue 开发:打造丝滑的缩略图列表(Thumbnail List)https://blog.csdn.net/qq_33650655/article/details/145776679
DeepSeek 助力 Vue 开发:打造丝滑的 键盘快捷键(Keyboard Shortcuts) https://blog.csdn.net/qq_33650655/article/details/145780227
DeepSeek 助力 Vue 开发:打造丝滑的评论系统(Comment System)https://blog.csdn.net/qq_33650655/article/details/145781104
DeepSeek 助力 Vue 开发:打造丝滑的二维码生成(QR Code)https://blog.csdn.net/qq_33650655/article/details/145797928
DeepSeek 助力 Vue 开发:打造丝滑的单选按钮(Radio Button)https://blog.csdn.net/qq_33650655/article/details/145810620
DeepSeek 助力 Vue 开发:打造丝滑的滑块(Slider)https://blog.csdn.net/qq_33650655/article/details/145817161
到此这篇文章就介绍到这了,更多精彩内容请关注本人以前的文章或继续浏览下面的文章,创作不易,如果能帮助到大家,希望大家多多支持宝码香车~,若转载本文,一定注明本文链接。
更多专栏订阅推荐:
html+css+js 绚丽效果
vue
✈️ Electron
⭐️ js
字符串
✍️ 时间对象(Date())操作