index.ts

index.ts

基本信息

  • 类型: TypeScript Barrel 文件
  • 路径: ./src/components/comments/index.ts

功能描述

评论组件模块的导出文件(Barrel Pattern),集中导出评论相关的所有组件,简化其他文件中的导入语句。

导出内容

导出名称来源路径描述
CommentForm./comment-form评论表单组件
CommentItem./comment-item评论项组件
CommentSection./comment-section评论区块组件

使用方式

// 通过 Barrel 文件导入(推荐)
import { CommentForm, CommentItem, CommentSection } from "@/components/comments";

// 直接导入(不推荐)
import { CommentForm } from "@/components/comments/comment-form";
import { CommentItem } from "@/components/comments/comment-item";
import { CommentSection } from "@/components/comments/comment-section";

优势

  • 简化导入路径
  • 统一组件入口
  • 便于重构时调整内部文件结构
  • 提高代码可维护性
← 返回目录