简体   繁体   English

Laravel Inertia 脚手架,但使用 vue2

[英]Laravel Inertia scaffolding but with vue2

The laravel starter kit install inertia with authorizations components in vue3. laravel 入门套件在 vue3 中使用授权组件安装惯性。 I must use vue2 because other reasons.由于其他原因,我必须使用 vue2。 Is there anyone who has been able to configure it using vue2有没有人能够使用 vue2 配置它

  • uninstall vue3 and install vue2卸载 vue3 并安装 vue2
  • uninstall inertia for vue3 and install the regular(compatible with vue2)卸载 vue3 的惯性并安装常规(与 vue2 兼容)

you need to install an older version for Jetstream, edit composer.json and change您需要为 Jetstream 安装旧版本,编辑 composer.json 并更改

"laravel/jetstream": "2.1.4"

And finally最后

npm install; npm run dev; php artisan migrate

If you check the installation guide here incase of vue2如果您在此处查看安装指南vue2

First第一的

Make sure that you remove inertia-vu3 like this确保像这样删除inertia-vu3

npm rm @inertiajs/inertia-vue3

Second第二

Install the Inertia client-side adapters using NPM or Yarn.使用 NPM 或 Yarn 安装 Inertia 客户端适配器。

npm install @inertiajs/inertia @inertiajs/inertia-vue
yarn add @inertiajs/inertia @inertiajs/inertia-vue

At the End在最后

Next, update your main JavaScript file to boot your Inertia app.接下来,更新您的主 JavaScript 文件以启动您的 Inertia 应用程序。 All we're doing here is initializing the client-side framework with the base Inertia component.我们在这里所做的只是使用基本 Inertia 组件初始化客户端框架。

import Vue from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue'

createInertiaApp({
  resolve: name => require(`./Pages/${name}`),
  setup({ el, App, props, plugin }) {
    Vue.use(plugin)

    new Vue({
      render: h => h(App, props),
    }).$mount(el)
  },
})

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

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