小编RFr*_*is6的帖子

将 sweet Alert 2 添加到 nuxt3 项目

我正在努力将 sweet Alert 2 作为插件集成到 nuxt3 应用程序中。我正在尝试使用vue-sweetalert2但我在某些时候它定义了全局变量。

// Inside the install function
vue.prototype.$swal = swalFunction;
vue['swal'] = swalFunction;
Run Code Online (Sandbox Code Playgroud)

你能帮我,如何访问这些全局变量吗?文档没有表明这一点。

我想目标是在我的插件中添加如下内容:

import VueSweetalert2 from 'vue-sweetalert2';
import 'sweetalert2/dist/sweetalert2.min.css';

export default defineNuxtPlugin((nuxtApp) => {
  nuxtApp.vueApp.use(VueSweetalert2)

  return {
    provide: {
      swal: swalFunction // <- how to access this ?
    }
  }
})
Run Code Online (Sandbox Code Playgroud)

nuxt.js sweetalert2 vuejs3 nuxtjs3

1
推荐指数
1
解决办法
5389
查看次数

标签 统计

nuxt.js ×1

nuxtjs3 ×1

sweetalert2 ×1

vuejs3 ×1