草庐IT

why-you-should-replace-enum-with-

全部标签

javascript - typescript 2.1 with async/await 为 angularjs 生成 ES5/ES3 目标

我正在尝试在一个Angular1.5.5项目中使用async/await。鉴于此服务方式getDocumentTypes():angular.IPromise{varurl="api/document/types";this.$log.log(url);returnthis.$http.get(url).then(_=>_.data);}我正在尝试创建该方法的async/await版本。asyncgetDocTypes():angular.IPromise{~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~}}Intellisenseshowsanerror:TS1055

javascript - 在特定索引处使用 .replace()

是否有一个函数可以在特定索引处将字符串中的字符串替换一次?示例:varstring1="mytextismytext";varstring2="my";string1.replaceAt(string2,"your",10);结果输出将是“我的文字就是你的文字”,或者:varstring1="mytextismytext";varstring2="my";string1.replaceAt(string2,"your",0);在这种情况下,结果将是“您的文本就是我的文本”。 最佳答案 functionReplaceAt(input,

Javascript ENUM 模式命名约定

我正在开发一个javascript项目,它需要使用javascript“枚举”,意思是像这样的对象:varWinnerEnum={Player1:1,Player2:2,Draw:0};这对我来说非常有用,但是,我不知道什么是正确的方式(根据惯例)命名枚举,因为据我所知只有类名以大写字母开头(表示能够调用上的构造函数)。JSHint还会输出以下警告:Missing'new'prefixwheninvokingaconstructor.如果没有约定,我希望有一种命名枚举的好方法,不会将它们与类名混淆。2014年更新:JSHint不再这样做。 最佳答案

javascript - jQuery 验证与 Summernote 编辑器错误 : Cannot read property 'replace' of undefined

我正在使用MVC5通过summernote编辑器构建一个表单。Razor代码:@Html.LabelFor(model=>model.Content,htmlAttributes:new{@class="control-label"})@Html.EditorFor(model=>model.Content,new{htmlAttributes=new{@class="form-controlpost-content"}})@Html.ValidationMessageFor(model=>model.Content,"",new{@class="text-danger"})JS:$(

javascript - 解析.com : Find all objects belonging to a user with objectId

我有一个解析类,比如图片。其中每一个都属于一个用户。对此用户的引用存储在图片表/类中作为指向用户的指针。在我的云代码中,我试图使用主key获取属于某个用户的所有图片。以下是我的代码:Parse.Cloud.define("getPictures",function(request,response){Parse.Cloud.useMasterKey();varquery=newParse.Query("Pictures");query.equalTo("user",request.params.user);query.find({success:function(results){va

javascript - 模拟 :starts-with or :ends-with for searching text? 的 jQuery 选择器

如果您查看selectorslist在jQuery网站上,有用于属性开始和结束的选择器。还有一个用于搜索文本的:contains选择器:alert($("div").find("span:contains(text)").html());jQuery是否有使用开头或结尾来搜索字符串的实现?仅供引用:我需要搜索XML对象。 最佳答案 据我所知不是默认情况下,但您可以通过$.expr[":"]添加自己的伪选择器:http://jsfiddle.net/h6KYk/.$.extend($.expr[":"],{"starts-with":

javascript - 此警告消息是什么意思? 'img elements must have an alt prop, either with meaningful text, or an empty string for decorative images'

为什么我会收到此警告?warning:imgelementsmusthaveanaltprop,eitherwithmeaningfultext,oranemptystringfordecorativeimagesjsx-a11y/img-has-alt它显示第13行,但没有使用任何Prop。 最佳答案 这意味着当您在HTML中创建图像时,为了屏幕阅读器和文本浏览器的利益,您应该包含一个alt属性。 关于javascript-此警告消息是什么意思?'imgelementsmusthave

javascript - Angular 错误 : [filter:notarray] Expected array but received: {} with a filter on an ng-repeat

我正在尝试使用ng-repeat指令使用对API的Angular请求来填充html表。首先加载html页面,然后请求获取返回响应时填充表格的数据。当我向ng-repeat指令添加过滤器时,表格被填充并且过滤器起作用,但是在我的chrome浏览器控制台中,我收到以下错误:Error:[filter:notarray]Expectedarraybutreceived:{}http://errors.angularjs.org/1.4.3/filter/notarray?p0=%7B%7DatREGEX_STRING_REGEXP(angular.js:68)atangular.js:182

javascript - 为什么我会收到 .replace 不是函数的错误消息?

这个问题在这里已经有了答案:var.replaceisnotafunction(10个答案)关闭8年前。我有这个功能:functioncountLitreKgSums(cProductIds){varcLitreKgSums=newArray();varcWeek=0;for(i=0;i我收到错误消息,指出.replace不是一个函数,但在其他函数中它可以正常工作。有什么区别?

javascript - window.location.replace() 无法重定向浏览器

我使用页面进行导航,但这段代码不起作用,这是什么问题?$(document).ready(function(){$("body").keydown(function(event){if(event.keyCode==37){//leftwindow.location.replace("http://newsii.abudayah.com/photo/2)";}elseif(event.keyCode==39){//rightwindow.location.replace("http://newsii.abudayah.com/photo/31)";}});});