【发布时间】:2021-11-22 12:12:26
【问题描述】:
之前我在没有配置 typescript 的情况下配置了我的 nuxt 项目,所以我根据这个文档为 nuxt 安装了 sweetalert2: https://www.npmjs.com/package/nuxt-sweetalert2 一切正常,然后我在同一个项目中设置了打字稿,我在 sweetalert 中有错误
我得到的错误是:
Property '$swal' does not exist on type 'CombinedVueInstance<Vue, { dinamic: { message: string; }; addFile: boolean; fields: { key: string; label: string; sortable: boolean; }[]; loading: boolean; dialogVisible: boolean; title: string; message: string; reason: boolean; ... 28 more ...; html: string; }, { ...; }, { ...; }, Readonly<...>>
我的使用方式是:
this.$swal({
title: "Has been deleted",
text: "the record you are accessing no longer exists",
type: "warning",
confirmButtonText: "OK"
});
我在nuxt中对typescript的配置是这样的:https://typescript.nuxtjs.org/es/guide/setup/
【问题讨论】:
-
dinamic?是不是哪里打错字了? -
我的组件中有几个打字稿错误,我正在纠正这些错误,但我不知道这个错误可能在哪里,或者我不知道是否应该配置一些打字稿
-
谢谢,我没有在“vue-sweetalert2”类型中添加
tsconfig.json
标签: typescript nuxt.js sweetalert2