我可能有一个简单的问题,但我真的不知道怎么做。
我想使用Sweetalert2,并在我拥有的每个VueJS组件中全局使用它。因此,在我的app.js中,我有以下内容:
import { createApp, h } from 'vue'
import { createInertiaApp } from '@inertiajs/inertia-vue3'
import { Head, Link } from '@inertiajs/inertia-vue3'
import { InertiaProgress } from '@inertiajs/progress'
import { Swal } from 'sweetalert2'
createInertiaApp({
resolve: name => require(`./Pages/${name}`),
setup({ el, App, props, plugin }) {
createApp({ render: () => h(App, props) })
.use(plugin)
.use(Swal)
.component('Link', Link)
.component('Head', Head)
.mount(el)
},
})
由于某些原因,这仍然会给出这个错误:(Picture)
发布于 2021-08-16 21:17:47
您是否尝试过使用默认导入
import Swal from 'sweetalert2'
发布于 2021-08-16 21:57:00
.component('Swal',require('sweetalert2').default);
为了使任何组件对所有vue组件都可用,您尝试过这种方式吗?
发布于 2021-08-20 17:05:53
尝试安装这个npm包:https://www.npmjs.com/package/vue-sweetalert2它是为vue 2和3制作的
https://stackoverflow.com/questions/68808006
复制相似问题