简体   繁体   English

并行使用 Laravel Inertia.js、Vue 和 Blade?

[英]Using Laravel Inertia.js, Vue and Blade in parallel?

Is there a way to use Laravel Blade for one part of a multipage site (e-commerce), and Inertia/Vue for some specific pages (like the basket and the admin pages)?有没有办法将 Laravel Blade 用于多页面网站(电子商务)的一部分,而将 Inertia/Vue 用于某些特定页面(如购物篮和管理页面)? Not mixing the two on the same pages, as I see it done with other commentaries.不要将两者混合在同一页面上,因为我看到它与其他评论一起完成。

The first category is a load of pages that are merely static, need fast loading and robust SEO referencing (product pages and catalogues).第一类是仅 static 的页面负载,需要快速加载和强大的 SEO 参考(产品页面和目录)。 The second do not need to be indexed, but need a lot of user interactions.第二个不需要被索引,但需要大量的用户交互。

I have tried a few things with my first project, but I don't seem to be able to call Laravel routes when Inertia is active.我在我的第一个项目中尝试了一些东西,但是当 Inertia 处于活动状态时,我似乎无法调用 Laravel 路线。 Plus it would not really make sense to load all Inertia and Vue in the Blade pages.另外,在 Blade 页面中加载所有 Inertia 和 Vue 并没有什么意义。 So as a starter I guess I would need to load the Inertia + Vue code only on the Vue pages (admin and basket).因此,作为初学者,我想我只需要在 Vue 页面(管理员和购物篮)上加载 Inertia + Vue 代码。 And I guess there are a lot of other issues to take care of.而且我想还有很多其他问题需要处理。

Or maybe scrap Inertia.js, and just load vanilla Vue.js on the Vue pages?或者可能废弃 Inertia.js,然后在 Vue 页面上加载 vanilla Vue.js? But then that means loading the router and the datastore as well...但这意味着还要加载路由器和数据存储......

Many thanks for any idea on the best way to proceed.非常感谢您对最佳方式的任何想法。 E. E.

You can mix pages as you want:您可以根据需要混合页面:

1. For Inertia pages. 1. 对于惯性页面。

    // View:
    <inertia-link href="/dashboard">dashboard</inertia-link>
    // Laravel controller:
    public function index(Request $request)
    {
        return Inertia::render('Dashboard/Index', [
            'data' => [
                // ...
            ],
        ]);
    }

2. Blade pages. 2. 刀片页面。

    // View:
    <a href="/dashboard">dashboard</a>
    // Laravel controller:
    public function index(Request $request)
    {
        return view('dashboard.index', [
            'data' => [
                // ...
            ],
        ]);
    }

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM