首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何用InertiaJS添加bootstrap-vue模块Laravel Jetstream?

如何用InertiaJS添加bootstrap-vue模块Laravel Jetstream?
EN

Stack Overflow用户
提问于 2021-03-22 08:39:20
回答 1查看 604关注 0票数 2

我如何在Laravel上使用bootstrap-vue,使用Laravel 8,Jetstream和InertiaJS?

代码语言:javascript
复制
import Vue from 'vue'
import { BootstrapVue, IconsPlugin } from 'bootstrap-vue'

// Import Bootstrap an BootstrapVue CSS files (order is important)
import 'bootstrap/dist/css/bootstrap.css'
import 'bootstrap-vue/dist/bootstrap-vue.css'

// Make BootstrapVue available throughout your project
Vue.use(BootstrapVue)
// Optionally install the BootstrapVue icon components plugin
Vue.use(IconsPlugin)

我不知道在哪里以及如何添加app.js文件。

app.js:

代码语言:javascript
复制
require('./bootstrap');

// Import modules...
import { createApp, h } from 'vue';
import { App as InertiaApp, plugin as InertiaPlugin } from '@inertiajs/inertia-vue3';
import { InertiaProgress } from '@inertiajs/progress';

const el = document.getElementById('app');

createApp({
    render: () =>
        h(InertiaApp, {
            initialPage: JSON.parse(el.dataset.page),
            resolveComponent: (name) => require(`./Pages/${name}`).default, 
        }),
})
    .mixin({ methods: { route } })
    .use(InertiaPlugin)
    .mount(el);

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

这是我的css.js。在这里添加CSS库。

代码语言:javascript
复制
@import 'tailwindcss/base';
@import 'tailwindcss/components';
@import 'tailwindcss/utilities';

@import 'bootstrap/dist/css/bootstrap.css';
@import 'bootstrap-vue/dist/bootstrap-vue.css';
EN

回答 1

Stack Overflow用户

发布于 2021-06-14 14:11:31

正如我从您的配置中看到的那样。您正在将InertiaJS与Vue3一起使用。目前,BootStrap-Vue组件仅适用于Vue2 (info)。因此,您需要首先将InertiaJS从Vue3降级为Vue2。使用npm。

代码语言:javascript
复制
npm uninstall @inertiajs/inertia-vue3 vue @vue/compiler-sfc vue-loader

npm install @inertiajs/inertia-vue vue vue-template-compiler vue-loader

卸载并重新安装vuevue-loader似乎很奇怪,但这是正确更新依赖项的最简单方法。

现在你需要放入你的app.js

代码语言:javascript
复制
import Vue from 'vue';
import { createInertiaApp } from '@inertiajs/inertia-vue';
import BootstrapVue from 'bootstrap-vue';

Vue.use(BootstrapVue);

createInertiaApp({
    resolve: (name) => require(`./Pages/${name}`),
    setup({ el, app, props }) {
        new Vue({
            render: (h) => h(app, props),
        }).$mount(el);
    }
});

app.css不需要任何修改。除非您需要修改和主题Bootstrap,在这种情况下,您必须更改为SASS。

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/66739014

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档