如何解决未捕获的类型错误:当代码在 2 个文件中分开时,r 不是构造函数
我遇到以下错误:
signorderView.js:20 Uncaught TypeError: r is not a constructor
这是 signorderView.js :
define([
'jquery','so!lib_dev/backbone.marionette','doT!suivi/js/template/details/signatureOrdre','../../common/countDownTimer'
],function(
$,Marionette,template,Timer
) {
'use strict';
const view = {
template : template,initialize : function () {
this.listenTo(this.model,'change',this.render);
Timer = new Timer(30);
},render: function () {
const data = setTemplateData(this.model);
updateRegiondisplay(this.$el,this.template(data));
},};
/*...*/
});
define(function () {
var CountDownTimer = (function () {
return {
CountDownTimer(duration,granularity) {
this.duration = duration;
this.granularity = granularity || 1000;
}
}
}());
return CountDownTimer;
});
为什么浏览器会抱怨 r
不是构造函数?
请注意,如果我将 CountDownTimer 代码直接放在 signorderView.js
文件中,它可以工作,但是我无法在其他地方重用 CountDownTimer 代码。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。