我不知道如何正确导入模块?
现在是这样的:
import noty from 'noty'
window.mindy = {
notify: (text, type = 'success') => {
noty({
text: text,
type: type,
theme: 'metroui',
layout: 'topRight',
timeout: false,
progressBar: false,
closeWith: ['click'],
animation: {
open: { height: 'toggle' },
close: { height: 'toggle' },
easing: 'swing',
speed: 300,
},
})
},
}
但它给出了一个错误
noty.js:2349
function _classCallCheck(instance, Constructor) { if (!
(instance instanceof Constructor)) { throw new TypeError("Cannot call
a class as a function"); } }
noty.js:2359
_classCallCheck(this, Noty)
该文件
noty.js
表明您使用的是第三版noty,而不是第二个(第二个版本在文件中jquery.noty.js
或jquery.noty.packaged.js
)在版本 3 中,Noty 是一个类,而不是一个函数,并且应该被称为
new Noty(...)
.