reactjs - 如何在我的 React 项目中导入 Flowbite?

标签 reactjs tailwind-css flowbite

我正在尝试将 Flowbite 添加到我的 React 项目中,但每次都会遇到此错误

Uncaught SyntaxError: expected expression, got '<'

我的 tailwind.config 文件是

module.exports = {
  content: ["./src/**/*.{js,jsx,ts,tsx}", "./node_modules/flowbite/**/*.js"],
  theme: {
    extend: {
      fontFamily: {
        sans: ["Rubik", "sans-serif"],
        kanit: ["Kanit", "sans-serif"],
      },
    },
  },
  plugins: [require("flowbite/plugin")],
};

我已经在index.js中包含了flowbite

import "flowbite";

最佳答案

您应该安装它:

npm i flowbite-react

然后使用以下命令导入到您的组件中:

import { Tooltip } from 'flowbite-react'

这是一个完整的示例:

import React from 'react'
import InfoIcon from '@mui/icons-material/Info'
import { Tooltip } from 'flowbite-react'

const InfoCircle = ({ tooltip }) => (
  <Tooltip content={tooltip}>
    <InfoIcon />
  </Tooltip>
)

export default InfoCircle

关于reactjs - 如何在我的 React 项目中导入 Flowbite?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/72162044/

相关文章:

node.js - Redux-Toolkit 中的 RTK 查询返回未定义的数据,当我 console.log 显示在控制台中的数据时

reactjs - 如何使用鼠标滚轮进行 react 水平滚动

javascript - 在 Vue JS 3 的 CSS 类中使用模板变量

reactjs - 如何在 create-react-app 中使用 tailwindcss/jit 库?

reactjs - React Query 处理响应状态代码

reactjs - react /TSX : child unable to infer correct generic type from parent

javascript - 如何将 Fabric js 与 React native 集成?