目前我有下面的JS。我正在嘗試運行slideout.close();
事件,其中smoothstate onStart
。我的代碼在下面,我目前在控制檯中出現錯誤。有人能幫助我嗎?函數沒有正確觸發
感謝。
$(document).ready(function() {
slideout();
});
function slideout() {
var slideout = new Slideout({
'panel': document.getElementById('slideout-content'),
'menu': document.getElementById('slideout-nav'),
'padding': 256,
'tolerance': 70,
'side': 'right'
});
$('.mobile-nav__icon').on('click', function() {
slideout.toggle();
});
}
$(function(){
'use strict';
var options = {
prefetch: true,
cacheLength: 2,
onStart: {
duration: 860,
render: function ($container) {
$container.addClass('is-exiting');
smoothState.restartCSSAnimations();
slideout.close();
}
},
onReady: {
duration: 0,
render: function ($container, $newContent) {
$container.removeClass('is-exiting');
$container.html($newContent);
}
},
onAfter: function() {
slideout();
}
},
smoothState = $('#animate-wrapper').smoothState(options).data('smoothState');
});
如果你指定什麼錯誤實際上是 – Li357
'的script.js我很偉大:29未捕獲TypeError:slideout.close不是函數' – Ryan
'slideout'是函數,而不是對象。也許你正試圖訪問本地的? – Li357