草庐IT

property_get

全部标签

javascript - 使用 angular-mocks 匹配所有 GET url for backendless

我现在正在编写一个没有后端ajax的前端。我正在使用angular-mocks来模拟这样的API调用:$httpBackend.when('GET','/somelink').respond(function(method,url,data){//dosomething});但是,如果ajax传递params:{id:12345},它将附加到url为'/somelink?id=12345'。catchwhen('GET','/somelink')有没有办法使用RegEx或一些技巧来解决这个问题?只是为了不管params里面有什么,respond()仍然会被调用?谢谢。更新1:我不能使用

javascript - 全日历 v2 错误 : Uncaught TypeError: Cannot read property 'month' of undefined

我在添加事件时使用了选择回调。以下代码在v1中有效,但我在v2中遇到了UncaughtTypeError。当我删除ajax代码时没有错误,但我当然需要将新事件添加到数据库中。select:function(start,end,jsEvent,view){vartitle='Available';vareventData;eventData={title:title,start:start};$.ajax({type:'POST',url:'add-event.php',data:eventData,success:function(data){$('#calendar').fullCa

javascript - React js 性能工具插件抛出 "Cannot read property ' 未定义的计数”

我对如何使用React的性能工具感到困惑。我目前的使用情况如下图:varPerf=React.addons.Perf;Perf.start();this.setState({newState:newStateObject,},function(){Perf.printInclusive();Perf.stop();});这不会在页面上呈现任何内容并脱口而出UncaughtTypeError:Cannotreadproperty'counts'ofundefined 最佳答案 参见https://github.com/facebook

javascript - 未捕获的类型错误 : Cannot set property offsetWidth of#<HTMLElement> which has only a getter

我正在使用AngularJS开发网络应用程序。我有一个不知从何而来的错误,它工作正常,但我真的不知道为什么它不再工作了。所以它在指令中,我尝试设置属性offsetWidth指令html模板中的一个元素。因为我真的不知道它可能来自哪里,所以我会给你我的指令和模板的完整代码。该指令创建一个应用程序按钮并处理其点击时的视觉效果。这是行$element[0].offsetWidth=$element[0].offsetWidth;这会触发错误。(这是重启动画的技巧)我再说一遍,这段代码工作正常而且我几乎可以肯定我没有做任何更改。我正在使用Chrome进行调试,也许它来自于它?错误:Uncaug

javascript - flowtype 绑定(bind)导致错误 `Convariant property incompatible with contravariant use in assignment of property`

这个表达式对于javascript/react来说非常简单,将函数绑定(bind)到this范围。this.toggle=this.toggle.bind(this);但是当引入flowtype时,会导致错误:我该怎么做才能通过流量测试?toggle可以是任何函数,甚至可以是空函数。toggle(){///donothing} 最佳答案 你必须在你的类中将你的toggle声明为Function(紧凑的方式):classFoo{toggle:Function=(){...}}或者,您可以将签名和实际方法分开:classFoo{togg

javascript - Chrome 扩展 : How to get user name?

我正在创建一个谷歌浏览器扩展程序。对于某些功能,我需要用户的系统登录名(无密码)。通过使用JavaScript,这是不可能的。有人建议NPAPI,但我对此一无所知,所以我放弃了。接下来我将尝试在Chrome浏览器中获取用户名。但仍然没有成功。我尝试使用类似的东西:varcurrentUser;varxhr=newXMLHttpRequest();xhr.onreadystatechange=function(data){if(xhr.readyState==1){currentUser=null;if(xhr.status==200){varre=newRegExp(/[\s]*([^

javascript - Phaser.js : cannot read property '0' on tiled map layer

我在Meteor.js服务器上使用Paser.js。在我尝试按照描述使用平铺map之前,它工作得很好here.这是我的代码:JS:if(Meteor.isClient){Template.Game.onCreated(function(){vargame=newPhaser.Game(800,600,Phaser.AUTO,'',{preload:preload,create:create,update:update});varmap;varbackgroundLayer;varblockLayer;varbg;functionpreload(){//loadallgameassets

javascript - jQuery.ajax() 在 Chrome 扩展中将 POST 请求作为 GET 发送

我正在构建一个小型Chrome扩展程序,它必须通过POSThttp请求将消息发送到我公司网络中的服务器,并且我正在使用jQuery1.4.1来加速javascript部分的开发。我有这个代码来发送请求:functionsend(){$.ajax({url:"http://mycompany.com/update",method:"POST",data:{status:"sometest",in_reply_to_status_id:"anId"},success:function(data,textStatus){console.log("success");console.log(d

JavaScript 语法错误 : invalid property id

我正在尝试执行以下JS代码;varfoo={  func1:function(){functiontest(){alert("123");}();    alert("456");  },myVar:'local'};但是我收到一个错误语法错误:无效的属性ID上面的代码有什么问题? 最佳答案 语法错误:varfoo={func1:function(){functiontest(){alert("123");}();//^Youcan'tinvokeafunctiondeclarationalert("456");},myVar:'l

javascript - $.get 中的 setState

当在$.get范围内使用this.setState()时,出现以下错误UncaughtTypeError:undefinedisnotafunction它在$.get范围之外工作正常。我该如何解决这个问题?$.get(APIURL,function(data){this.setState({resdata:"Thisisanewstate"});});我不确定将jQueryAJAX替换为其他小型AJAX库的最佳做法是什么。 最佳答案 您可以保存对外部this的引用:varthat=this;$.get(APIURL,function