Vue3炫酷动画库Vue Bits使用笔记

Vue3 集成动画库 Vue Bits

Vue Bits使用 jsrepo 的脚手架安装组件,官方文档中每个组件都有安装步骤。

一、全局安装 jsrepo

复制代码
npm install jsrepo -g

二、初始化项目 jsrepo

csharp 复制代码
npx jsrepo init https://vue-bits.dev/ui

三、完成第二步的配置选项后会在根目录生成一个jsrepo.json文件

json 复制代码
{
  "$schema": "https://unpkg.com/jsrepo@2.4.5/schemas/project-config.json",
  "repos": ["https://vue-bits.dev/ui"],
  "includeTests": false,
  "includeDocs": false,
  "watermark": true,
  "formatter": "prettier",
  "configFiles": {},
  "paths": {
    "*": "./src/blocks",
    "Animations": "./src/Animations",
    "Backgrounds": "./src/Backgrounds",
    "Components": "./src/Components",
    "TextAnimations": "./src/TextAnimations"
  }
}

四、使用安装需要的组件,以 SplitText 文本动画组件为例子

csharp 复制代码
npx jsrepo add https://vue-bits.dev/ui/TextAnimations/SplitText

执行命令后安装组件代码。在vue中使用(注意安装组件路径):

javascript 复制代码
<template>
  <SplitText
    text="Hello, GSAP!"
    class-name="text-2xl font-semibold text-center"
    :delay="100"
    :duration="0.6"
    ease="power3.out"
    split-type="chars"
    :from="{ opacity: 0, y: 40 }"
    :to="{ opacity: 1, y: 0 }"
    :threshold="0.1"
    root-margin="-100px"
    text-align="center"
    @animation-complete="handleAnimationComplete"
  />
</template>

<script setup>
  import SplitText from "./SplitText.vue";

  const handleAnimationComplete = () => {
    console.log('All letters have animated!');
  };
</script>
相关推荐
却尘3 小时前
Next.js 请求最佳实践 - vercel 2026一月发布指南
前端·react.js·next.js
ccnocare3 小时前
浅浅看一下设计模式
前端
Lee川3 小时前
🎬 从标签到屏幕:揭秘现代网页构建与适配之道
前端·面试
Ticnix3 小时前
ECharts初始化、销毁、resize 适配组件封装(含完整封装代码)
前端·echarts
纯爱掌门人3 小时前
终焉轮回里,藏着 AI 与人类的答案
前端·人工智能·aigc
twl3 小时前
OpenClaw 深度技术解析
前端
崔庆才丨静觅3 小时前
比官方便宜一半以上!Grok API 申请及使用
前端
星光不问赶路人3 小时前
vue3使用jsx语法详解
前端·vue.js
天蓝色的鱼鱼4 小时前
shadcn/ui,给你一个真正可控的UI组件库
前端
布列瑟农的星空4 小时前
前端都能看懂的Rust入门教程(三)——控制流语句
前端·后端·rust