通过将onAfter脚本移至主要的smoothstate函数(删除了其他smoothstate函数),我设法在代码的末尾运行了一个单独的函数。在刷新浏览器的情况下,也可以在准备好的文档上运行函数。如果它与您的代码相同,则如下所示:
$(document).ready(function() { mail(); }); function mail() { // script from mail.js goes here } $(function() { "use strict"; var options = { prefetch: true, pageCacheSize: 3, onStart: { duration: 250, // Duration of our animation render: function($container) { // Add your CSS animation reversing class $container.addClass("is-exiting"); // Restart your animation smoothState.restartCSSAnimations(); } }, onReady: { duration: 0, render: function($container, $newContent) { // Remove your CSS animation reversing class $container.removeClass("is-exiting"); // Inject the new content $container.html($newContent); } }, onAfter: function() { mail(); } }, smoothState = $("#main").smoothState(options).data("smoothState"); });


