🌐 Nodejs.cn

安装并配置带有 Inertia 的 Laravel

创建项目

🌐 Create project

首先使用 Laravel 安装器 laravel new my-app 创建一个带有 Inertia 和 Vue 的新 Laravel 项目:

🌐 Start by creating a new Laravel project with Inertia and Vue using the laravel installer laravel new my-app:

laravel new my-app --vue

添加组件

🌐 Add Components

你现在可以开始向你的项目添加组件。

🌐 You can now start adding components to your project.

pnpm dlx shadcn-vue@latest add switch

上面的命令将会把 Switch 组件添加到 resources/js/components/ui/switch。然后你可以像这样导入它:

🌐 The command above will add the Switch component to resources/js/components/ui/switch. You can then import it like this:

resources/js/pages/index.vue
<script setup lang="ts">
import { Switch } from '@/Components/ui/switch'
</script>

<template>
  <div>
    <Switch />
  </div>
</template>