Docs
Laravel
Laravel
使用 Inertia 安装并配置 Laravel
创建项目
¥Create project
首先使用 laravel 安装程序 laravel new my-app
创建包含 Inertia 和 React 的新 Laravel 项目:
¥Start by creating a new Laravel project with Inertia and React using the laravel installer laravel new my-app
:
laravel new my-app --typescript --breeze --stack=react --git --no-interaction
运行 CLI
¥Run the CLI
运行 shadcn
init 命令来设置你的项目:
¥Run the shadcn
init command to setup your project:
pnpm dlx shadcn@latest init
配置 components.json
¥Configure components.json
你将被问到几个问题来配置 components.json
:
¥You will be asked a few questions to configure components.json
:
Which style would you like to use?
Which color would you like to use as base color?
Do you want to use CSS variables for colors? › yes
就是这样
¥That's it
你现在可以开始向你的项目添加组件。
¥You can now start adding components to your project.
pnpm dlx shadcn@latest add button
上面的命令将把 Button
组件添加到你的项目中。然后你可以像这样导入它:
¥The command above will add the Button
component to your project. You can then import it like this:
import { Button } from "@/Components/ui/button"
export default function Home() {
return (
<div>
<Button>Click me</Button>
</div>
)
}