将jQuery与javascript结合使用
更新:当我在StackOverflow中按enter键时,意外提交了!目前正在更新帖子 更新2:完成发布 我目前在Electron中将Javascript与jQuery相结合时遇到了一个问题 我大部分时间都在运行javascript,但为了给应用程序一种更自然的感觉,我发现将jQuery与javascript结合使用,javascript,jquery,electron,smoothstate.js,Javascript,Jquery,Electron,Smoothstate.js,更新:当我在StackOverflow中按enter键时,意外提交了!目前正在更新帖子 更新2:完成发布 我目前在Electron中将Javascript与jQuery相结合时遇到了一个问题 我大部分时间都在运行javascript,但为了给应用程序一种更自然的感觉,我发现smoothState.js。它按预期工作,但由于某种原因,如果它被激活,它会破坏我的所有其他JS代码 以my HTML中的以下代码段为例: <div id="title-bar"> <div
smoothState.js
。它按预期工作,但由于某种原因,如果它被激活,它会破坏我的所有其他JS代码
以my HTML中的以下代码段为例:
<div id="title-bar">
<div id="title-bar-btns">
<a id="min-btn"><img src="../Resources/Minimize_button.svg" height="25px" width="25px" /></a>
<a id="max-btn"><img src="../Resources/Maximize_button.svg" height="25px" width="25px" /></a>
<a id="close-btn"><img src="../Resources/Cross_button.svg" height="25px" width="25px" /></a>
</div>
</div>
当smoothState未激活(或只是注释掉代码)时,此功能就会起作用。然而,当smoothState被触发时,我的所有普通JS代码都不再工作了。我有很多依赖于JS的按钮,如上面的例子
Jquery按如下方式导入(通过npm安装):
smoothState的代码只是示例的一个小变化:
window.$(document).ready(function(){
'use strict';
var $page = window.$('#main'),
options = {
debug: true,
prefetch: true,
cacheLength: 4,
onStart: {
duration: 100, // 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);
}
}
},
smoothState = $page.smoothState(options).data('smoothState');
});
那么,如果有可能的话,我可以结合使用smoothState.js、jQuery和normal js而不互相破坏吗\
编辑:您也可以使用此要点作为参考:您是否可以共享链接您是否检查了开发人员控制台是否显示了一些javascript错误?没有显示错误不幸的是您可以共享链接您是否检查了开发人员控制台是否显示了一些javascript错误?没有显示错误不幸的是
window.$ = window.jQuery = require('jquery');
window.$(document).ready(function(){
'use strict';
var $page = window.$('#main'),
options = {
debug: true,
prefetch: true,
cacheLength: 4,
onStart: {
duration: 100, // 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);
}
}
},
smoothState = $page.smoothState(options).data('smoothState');
});