草庐IT

this-is-a-collection

全部标签

javascript - 在 React JS 的 this.setState 回调中使用 this.setState?

是否可以在this.setState的回调中调用this.setState?我正在制作一个RoguelikeDungeon并有一个设置,其中在this.setState的回调中使用了一个辅助函数,它再次调用this.setState。我的游戏此时卡住。所以我在React组件中有一个对象,它有一个生成随机二维数组映射的方法:this.Dungeon.Generate();当游戏开始时,我们在componentDidMount()中调用组件中的如下函数:componentDidMount:function(){this.Dungeon.Generate();this.setState({b

javascript - 剧情 js : how to run my javascript ONLY after plot image is loaded

当通过JavascriptAPI(plotly.js,而不是plotly-nodejs)使用任何类型的plotly图表时,我如何才能在图表加载后运行一些javascript?我正在寻找plotlyjavascriptAPI中的机制,例如,在使用GoogleMapsAPI时,它与“addListenerOnce”结合“tilesloaded”或“ready”执行相同的操作。例如,假设我想在呈现https://plot.ly/~PlotBot/685处显示的示例后立即简单地显示一个警报,其html和js代码可以在https://plot.ly/~PlotBot/685.js查看.这样做的原

javascript - 错误 : 'jQuery is not defined'

我用jQuery写了一个脚本。它适用于Firefox和GoogleChrome。只有在IE中我才返回这个错误:'jQuery'isnotdefinedjquery-ui-1.8.4.custom.min.js,Row10Character1这是我页面的头部:Contattaci-TheItalianBrand.com$(function(){$('#dialog_link,ul#iconsli').hover(function(){$(this).addClass('ui-state-hover');},function(){$(this).removeClass('ui-state-

JavaScript 本地作用域 : var vs. this

我似乎无法理解JavaScript变量作用域的特定情况。与我发现的其他示例和问题不同,我对嵌套函数的范围界定很感兴趣。我在thisJSFiddle设置了一个示例.相关部分如下:functionMyObject(){varself=this;vara=1;this.b=2;varinnerMethod=function(){//1and2:directreferencelogMessage("a="+a);//a=1//logMessage("b="+b);//Error:bisnotdefined//3and4:usingthislogMessage("this.a="+this.a)

javascript - 类型错误 : 'undefined' is not an object

我有一个目前相当不正常的Javascript程序,它一直给我带来问题。但是,它引发了一个我不明白的错误:TypeError:'undefined'isnotanobject(evaluating'sub.from.length')正如您可能猜到的那样,我正在尝试做的是检查lengthfrom中的某个“sub”数组字典。这是sourcecodefortheentirefunction,这是我认为导致错误的循环代码:console.log(afcHelper_ffuSubmissions.length);//justfordebugging,returnsthecorrectnumberf

Javascript:Promises + this

这个问题在这里已经有了答案:Howdoesthe"this"keywordwork,andwhenshoulditbeused?(22个答案)关闭6年前。考虑以下代码:foo:function(){varself=this;varp1=p2=someFunctionThatReturnsAPromise();Promise.all([p1,p2]).then(self.bar);}bar:function(promises){varself=this;console.log(self);}输出:undefined但如果我改为执行以下操作:foo:function(){varself=t

javascript - LinkedIn OAuth 重定向登录返回 "No ' Access-Control-Allow-Origin' header is present on the requested resource“错误

我目前正在我的React和Play应用程序中使用LinkedIn实现OAuth登录,并在尝试重定向到我的开发环境中的授权页面时遇到CORS错误:XMLHttpRequest无法加载https://www.linkedin.com/oauth/v2/authorization?response_type=code&client_i…basicprofile&redirect_uri=http%3A%2F%2Flocalhost%3A9000%2Fusers%2Flinkedin。从'https://www.linkedin.com/oauth/v2/authorization?respo

javascript - 箭头函数的 this 值

这个问题在这里已经有了答案:MethodsinES6objects:usingarrowfunctions(6个答案)Howdoesthe"this"keywordinJavascriptactwithinanobjectliteral?[duplicate](4个答案)关闭5年前。我正在尝试理解ECMAScript6中的箭头函数。这是我在阅读时遇到的定义:Arrowfunctionshaveimplicitthisbinding,whichmeansthatthevalueofthethisvalueinsideofanarrowfunctionisawaysthesameasthe

javascript - 高库存,错误 : Uncaught TypeError: w[(intermediate value)(intermediate value)(intermediate value)] is not a constructor

我正在尝试创建highstock图表,但出现以下错误:error:UncaughtTypeError:w[(intermediatevalue)(intermediatevalue)(intermediatevalue)]isnotaconstructor我的JSON似乎有效,我的javascript也有效,知道如何解决这个问题吗?Javascript:$.getJSON('analytic/weekly_views_json',function(data){//Createthechart$('#container2').highcharts('StockChart',{rangeS

javascript - Chrome 扩展中的 Require.JS : define is not defined

我正在尝试在我的chrome扩展程序中使用Requre.js。这是我的list:{"name":"myextension","version":"1.0","manifest_version":2,"permissions":["http://localhost/*"],"web_accessible_resources":["js/test.js"],"content_scripts":[{"matches":["http://localhost/*"],"js":["js/require.js","js/hd_init.js"]}]}hd_init.jsconsole.log("h