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>
相关推荐
涵涵(互关)17 小时前
语法大全-only-writer-two
前端·vue.js·typescript
huangql52017 小时前
浏览器 Location API、History API、路由记录与支付跳转完全指南
前端
木斯佳17 小时前
前端八股文面经大全:腾讯前端实习一面(2026-04-27)·面经深度解析
前端·八股·面经
sayamber17 小时前
Kubernetes 生产环境避坑指南:10 个真实故障案例与解决方案
前端
清寒_17 小时前
分层理解AI架构,降低对AI复杂度的恐惧
前端·人工智能·ai编程
李白的天不白18 小时前
如何项目发布到github上
android·vue.js
牧码岛18 小时前
Web前端之JavaScrip中的Array、Object、Map和Set详解
前端·javascript·web·web前端
Bigger18 小时前
😮‍💨 有了 AI 之后,我怎么感觉反而更累了?
前端·aigc·ai编程
Dxy123931021618 小时前
HTML中使用Canvas动态图形渲染:解锁Web交互新维度
前端·html·图形渲染
西陵18 小时前
如何实现 Claude 生成式 UI?一套可落地的工程方案
前端·人工智能·ai编程