我对Javascript / jQuery的了解很少,所以不确定这是多么容易修复...我有以下脚本来切换单独页面底部的4个隐藏div,它在Internet Explorer中工作正常( IE 11)。
调试器说" jQuery.Deferred异常:对象不支持属性或方法' assign' TypeError:对象不支持属性或方法' assign'"我的脚本中有Object.assign。我只是想知道是否有人知道替代解决方案?
我的代码如下:
(function($) {
jQuery(document).ready(function() {
var panel1 = new Panel(1),
panel2 = new Panel(2); panel3 = new Panel(3); panel4 = new Panel(4);
$(document).on('click', '.tab-controller1', function() {
panel1.togglePanel();
});
$(document).on('click', '.tab-controller2', function() {
panel2.togglePanel();
}); $(document).on('click', '.tab-controller3', function() {
panel3.togglePanel();
}); $(document).on('click', '.tab-controller4', function() {
panel4.togglePanel();
});
});
// Constructor. Needs to get the number 1 or 2
function Panel(num) {
var that = this; // Remember the object that is created here
Object.assign(that, {
isVisible : false,
showMessage : null,
hideMessage : null,
animationDuration : 300,
animationEasing : 'linear',
init: function() {
that.hidePanel();
},
hidePanel : function() {
// Use number to address the correct class, here and below.
$('.infoToggle' + num).animate({
bottom : -(that.getAnimationOffset())
}, that.animationDuration, that.animationEasing, function() {
that.isVisible = false;
that.updateTabMessage();
});
},
showPanel : function() {
$('.infoToggle' + num).animate({
bottom : 0
}, that.animationDuration, that.animationEasing, function() {
that.isVisible = true;
that.updateTabMessage();
});
},
togglePanel : function() {
(that.isVisible ? that.hidePanel : that.showPanel)();
},
updateTabMessage : function() {
if (that.isVisible) {
$('.tab-controller' + num + ' .close').show();
$('.tab-controller' + num + ' .show').hide();
} else {
$('.tab-controller' + num + ' .close').hide();
$('.tab-controller' + num + ' .show').show();
}
},
getAnimationOffset : function() {
return $('.panel-content' + num).height();
}
});
// call init here, which will execute when you do `new Panel`:
that.init();
} })(jQuery);
提前致谢。
答案 0 :(得分:0)