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>
相关推荐
jump_jump12 分钟前
超长定时器 long-timeout
前端·javascript·node.js
Mintopia1 小时前
架构进阶 🏗 从 CRUD 升级到“大工程师视野”
前端·javascript·全栈
Mintopia1 小时前
小样本学习在 WebAI 场景中的技术应用与局限
前端·人工智能·aigc
光影少年1 小时前
vue生态都有哪些?
前端·javascript·vue.js
一只大头猿1 小时前
基于SpringBoot和Vue的超市管理系统
前端·vue.js·spring boot
用户1456775610372 小时前
告别繁琐操作!Excel合并原来可以这么轻松
前端
itslife2 小时前
vite 源码 - 创建 ws 服务
前端·javascript
懒人Ethan2 小时前
解决一个C# 在Framework 4.5反序列化的问题
java·前端·c#
用户1456775610372 小时前
Excel合并数据太麻烦?这个神器3秒搞定,打工人必备!
前端
西洼工作室3 小时前
前端混入与组合实战指南
前端