javascript 错误:无法访问词法声明
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/31068665/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Error: Can't access lexical declaration
提问by Nona Haron
let textBytes = ctypes.uint8_t("hello");
let a = new SECItem;
a.type = siBuffer;
a.data = textBytes.address();
a.len = textBytes.length;
I got ReferenceError: can't access lexical declaration textBytes before initialization.
我得到了 ReferenceError: can't access lexical Declaration textBytes before Initialization。
回答by Noitidart
I can't reproduce the reference error you are getting, but I think change
我无法重现你得到的参考错误,但我认为改变
let textBytes = ctypes.uint8_t("hello");
as this throws TypeError: expected type uint8_t, got "hello"
to
因为这将引发TypeError: expected type uint8_t, got "hello"
对
let textBytes = ctypes.uint8_t.array()("hello");
This will give you a null-terminated string, of length 6. If you want it to be length 5, no null termination then do let textBytes = ctypes.uint8_t.array(5)("hello");
这将为您提供一个长度为 6 的空终止字符串。如果您希望它的长度为 5,则没有空终止然后执行 let textBytes = ctypes.uint8_t.array(5)("hello");
as I am thinking, change
正如我所想,改变
let a = new SECItem;
to
到
let a = SECItem();
or let a = new SECItem();
they are both same.
或者let a = new SECItem();
他们都是一样的。
If that doesn't fix it, please share the structure of SECItem
and what is siBuffer
.
如果不解决这个问题,请分享的结构SECItem
,什么是siBuffer
。