草庐IT

code_review_assigned_count

全部标签

javascript - Websocket 错误 : Error during WebSocket handshake: No response code found in status line

我想与我的服务器建立一个tcp连接。但是我每次都会出错...WebSocketconnectionto'ws://my.ip:1337/'failed:ErrorduringWebSockethandshake:Noresponsecodefoundinstatusline:Echoserver客户:varconnection=newWebSocket('ws://my.ip:1337');connection.onopen=function(){connection.send('Ping');//Sendthemessage'Ping'totheserver};服务器:varnet=

javascript - Object.assign 构造函数中的 getter 和 setter

我尝试通过Object.assign在构造函数中定义getter和setter:functionClass(){Object.assign(this,{getprop(){console.log('callget')},setprop(v){console.log('callset')},});}varc=newClass();//(1)=>'callget'console.log(c.prop);//(2)=>undefinedc.prop='change';console.log(c.prop);//(3)=>'change'问题:(1)为什么要调用getter?(2)为什么不调用

javascript - JS函数声明: curly brace object assigned with an empty object in parameter declaration

这是代码,exportfunctioncreateConnect({connectHOC=connectAdvanced,mapStateToPropsFactories=defaultMapStateToPropsFactories,mapDispatchToPropsFactories=defaultMapDispatchToPropsFactories,mergePropsFactories=defaultMergePropsFactories,selectorFactory=defaultSelectorFactory}={}){...}函数参数声明中的{connectHOC=

javascript - 中级 JavaScript : assign a function with its parameter to a variable and execute later

我有一个JavaScript函数:functionalertMe($a){alert($a);}我可以这样执行:alertMe("Hello");我想做的是将带有"Hello"参数的alertMe("Hello")赋给一个变量$func,然后稍后可以通过执行$func();之类的操作来执行此操作。 最佳答案 我想添加评论作为答案代码//definethefunctionfunctionalertMe(a){//returnthewrappedfunctionreturnfunction(){alert(a);}}//declaret

javascript - 如何从 Visual Studio Code API 打开浏览器

我只是在探索一种方法,以便从用于开发扩展的VisualStudioCodeAPI打开默认浏览器。以下是我的代码:vardisposable=vscode.commands.registerCommand('extension.browser',()=>{//Thecodeyouplaceherewillbeexecutedeverytimeyourcommandisexecutedvscode.Uri.call("http://facebook.com");});如何使用vscode类从API打开浏览器URL。 最佳答案 不需要No

javascript - Angular 2 : how do display character count on reactive form input

我正在使用Angular2响应式表单,我想在用户输入时显示textarea的字符数。我希望能够像这样在我的html中包含表单控件的name.length:BriefDescriptionofIncident{{alaynaPage.incidentDescription.length}}of{{maxIncidentDescriptionLength}}characters这“有效”,但是表单控件的length滞后一次击键。例如,如果我在文本区域中键入a,{{alaynaPage.incidentDescription.length}}为0。如果我随后键入b(因此字符串是ab){{al

使用 "this = "的 Javascript 函数给出 "Invalid left-hand side in assignment"

我试图让一个JavaScript对象使用另一个对象的构造函数的“this”赋值,并假定所有对象的原型(prototype)函数。这是我试图完成的示例:/*Thebase-containsassignmentsto'this',andprototypefunctions*/functionObjX(a,b){this.$a=a;this.$b=b;}ObjX.prototype.getB(){returnthis.$b;}functionObjY(a,b,c){//here'swhatI'mthinkingshouldwork:this=ObjX(a,b*12);/*andby'work

javascript - 在 VS Code EADDRINUSE 错误上调试 Node.JS

我正在尝试在VSCode上调试Node.JS应用程序,但是当终端打开时,我收到此消息:错误:听EADDRINUSE:::5858我的应用程序使用名为StrawJS(https://github.com/simonswain/straw)的框架,它会同时启动一些不同的进程。我认为这是错误的原因,因为有许多不同的进程试图使用同一个调试器。我发现了一个类似的问题(VSCodewillnotstoponbreakpointswhenfirstnodeprcessforksasecond),但是在attach.js文件上配置端口不起作用,问题仍然存在。这是我实际的launch.json文件:{"

javascript - 使用 Visual Studio Code 调试 Chrome 扩展

有谁知道是否可以使用VisualStudioCode调试Chrome扩展?我读过的所有示例都涉及一个带有url的真实网页。 最佳答案 对于那些仍在寻找答案的人(如我,早些时候),我已经找到了真正的解决方案,这就是它。这假设你有DebuggerforChrome已经安装。不像Firefox那样拥有native配置支持,您需要在运行Chrome之前提供加载扩展的参数,特别是load-extension参数。将此行添加到您的Chrome配置对象中,启动请求位于您的.vscode/launch.json文件中。这假定您的manifest.j

javascript - Typescript "Cannot assign to property, because it is a constant or read-only"即使属性未标记为只读

我有以下代码typeSetupProps={defaults:string;}exportclassSetupextendsReact.Component{constructor(props:any){super(props);this.props.defaults="Whatever";}尝试运行此代码时,TS编译器返回以下错误:Cannotassignto'defaults'becauseitisaconstantoraread-onlyproperty.deafualts是只读属性,但显然没有这样标记。 最佳答案 您正在扩展R