2017-08-31 55 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

相关问题