You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何在 Laravel 8 Jetstream + Inertia 项目中接入 Vuetify 3?

你已经完成了Vuetify 3的样式导入和实例初始化,仅需在Inertia的应用注册逻辑中追加Vuetify实例的注册步骤即可,修改后的app.js代码如下:

require('./bootstrap');

import { createApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';

import 'vuetify/styles';
import { createVuetify } from 'vuetify';

const appName = window.document.getElementsByTagName('title')[0]?.innerText || 'Laravel';
// 如需自定义主题、组件默认配置等,可在createVuetify的入参中传入配置对象
const vuetify = createVuetify();

createInertiaApp({
    title: (title) => `${title} - ${appName}`,
    resolve: (name) => require(`./Pages/${name}.vue`),
    setup({ el, app, props, plugin }) {
        return createApp({ render: () => h(app, props) })
            .use(plugin)
            .use(vuetify) // 注册Vuetify插件
            .mixin({ methods: { route } })
            .mount(el);
    },
});

InertiaProgress.init({ color: '#4B5563' });

修改完成后重新编译前端资源,即可在项目所有Vue页面组件中直接使用Vuetify的组件、指令等能力。

内容的提问来源于stack exchange,提问作者reylimjr

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.10.01 16:24:04