2017-08-31 49 views
0

我有這個,這是我從JQueryTerminal代碼的最新的zip編輯:爲什麼jqueryterminal cmd函數不起作用?

<html> 
<head> 
    <meta charset="utf-8" /> 
    <title>JQuery Terminal Emulator Demo</title> 
    <script src="../js/jquery-1.7.1.min.js"></script> 
    <script src="../js/jquery.mousewheel-min.js"></script> 
    <script src="../js/jquery.terminal.min.js"></script> 
    <link href="../css/jquery.terminal.css" rel="stylesheet"/> 
    </head> 

    <body> 
    <div id="some_id"></div> 
</body> 


    <script> 

    $('#some_id').cmd({ 
     prompt: '> ', 
     width: '100%', 
     commands: function(command) { 
      //process user commands 
     } 
    }); 

</script> 
</html> 

的。加利福尼亞是直接從網站http://terminal.jcubic.pl/api_reference.php#cmd拍攝。爲什麼我在Firefox的Javascript控制檯中得到這個:

TypeError: $ is undefined[Learn More] jquery.terminal.min.js:36:23429

謝謝!

編輯:

我不應該得到一個404基於我上的蒂爾達 - demo.html文件中的examples文件夾,並把它放在同一個文件夾。我剛剛檢查了開發者工具。沒有404.是否有其他原因?

編輯:

這裏有更多的錯誤消息:

ke file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656/js/jquery.terminal.min.js:36:23429 dispatch file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656>/js/jquery-1.7.1.min.js:3:4299 i file:///Volumes/Macintosh%20HD/jcubic-jquery.terminal-26bc656/js/jquery-1.7.1.min.js:3:311

只是爲了記錄在案,我得到這個版本的Chrome Canary當我輸入 'ASDSF':

jquery.terminal.min.js:36 binded jquery.terminal.min.js:36 true jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'A' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'S' > of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'D' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'S' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3) jquery.terminal.min.js:36 Uncaught TypeError: Cannot read property 'F' of undefined at HTMLHtmlElement.ke (jquery.terminal.min.js:36) at HTMLHtmlElement.dispatch (jquery-1.7.1.min.js:3) at HTMLHtmlElement.i (jquery-1.7.1.min.js:3)

+0

也許你有404的jQuery,請檢查開發人員工具。下面是使用相同代碼的工作示例https://codepen.io/jcubic/pen/XaoqGp – jcubic

+0

呃,什麼?你是說它在鉻但不是Firefox的作​​品?你在chrome中出現的錯誤可能是由於'//處理用戶命令'中的某些內容引起的,這與你在最初提出的問題中出現的錯誤完全不相關。 –

回答

0

謝謝對於你的帖子,@ jcubic。我找到了解決方案。我需要添加鍵盤映射。現在它完美地工作。代碼現在看起來像這樣:

$('#some_id').cmd({ 
    prompt: '> ', 
    width: '100%', 
    keymap: function(command) { 
    }, 
    commands: function(command) { 
      console.log(command); 
    } 
}); 
+0

這絕對是一個錯誤,鍵盤映射應該是一個對象 – jcubic

+0

該修復將在下一個1.6.5版本 – jcubic

相關問題