javascript - VueJS 3 全局注册导入
问题描述
我可能有一个简单的问题,但我并没有真正知道如何去做。
我想使用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)
},
})
由于某种原因,这仍然会出现此错误:( 图片)
解决方案
您是否尝试过使用默认导入
import Swal from 'sweetalert2'
推荐阅读
- apache-spark - Pyspark 中的表格显示来自 CSV 文件的标题
- mysql - 是否有可能在数据库触发器中使用多个 Before 或 After 语句
- python - 如何在 Django Rest Framework 中接收我不想存储的 json 字段?
- python - 如何将日期时间对象的格式更改为指定格式?
- c - sscanf: %* 不会忽略空字段
- python - 如何使用 sklearn 对 CSV 文件中的多列进行一次热编码?
- docker - Blazor WebAssembly 在 Docker 中运行时无法读取环境变量或查找文件
- .net-core - 服务器端 Blazor 中的缓存控制 JSS / JS 文件
- javascript - 在 React 中添加带有超时的悬停效果
- html - 如何修复无法正常响应的导航栏