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>
相关推荐
大怪v34 分钟前
AI抢饭?前端佬:我要验牌!
前端·人工智能·程序员
新酱爱学习34 分钟前
字节外包一年,我的技术成长之路
前端·程序员·年终总结
小兵张健44 分钟前
开源 playwright-pool 会话池来了
前端·javascript·github
IT_陈寒4 小时前
Python开发者必知的5大性能陷阱:90%的人都踩过的坑!
前端·人工智能·后端
codingWhat4 小时前
介绍一个手势识别库——AlloyFinger
前端·javascript·vue.js
代码老中医4 小时前
2026年CSS彻底疯了:这6个新特性让我删掉了三分之一JS代码
前端
不会敲代码14 小时前
Zustand:轻量级状态管理,从入门到实践
前端·typescript
踩着两条虫4 小时前
VTJ.PRO 双向代码转换原理揭秘
前端·vue.js·人工智能
扉川川4 小时前
OpenClaw 架构解析:一个生产级 AI Agent 是如何设计的
前端·人工智能
远山枫谷4 小时前
一文理清页面/组件通信与 Store 全局状态管理
前端·微信小程序