草庐IT

tsconfig.json的作用

全部标签

javascript - 为什么我们需要使用 package.json?

这个问题在这里已经有了答案:WhatarethemainusesfortheNPMpackage.jsonfile?(2个答案)关闭6年前。我正在尝试使用JavaScript学习网络套接字site,但我不明白为什么我需要使用package.json。这是我的package.json文件代码:`{"name":"module-name","version":"10.3.1","description":"Anexamplemoduletoillustratetheusageofapackage.json","author":"YourName","contributors":[{"nam

javascript - 简单的 Angular 应用程序不起作用

我正在尝试创建基本的Angular应用程序,但它抛出了一个错误varangularApp=angular.module('angularApp',[]);angularApp.controller('Ctrl',function($scope){});错误:Error:[ng:areq]http://errors.angularjs.org/1.4.3/ng/areq?p0=Ctrl&p1=not%20a%20function%2C%20got%20undefinedatError(native)athttps://ajax.googleapis.com/ajax/libs/angul

javascript - Chrome 中的 ES6 - Babel Sourcemaps 和 Arrow Functions 词法作用域

我在ES6class中有一个函数:classTest{//OmittedcodeforbrevityloadEvents(){$.get('/api/v1/events',(data)=>{this.actions.setEvents(data);});}}Babel将this转换为不同的形式,并生成一个_this变量来控制箭头函数的词法范围。var_this=this;$.get('/api/v1/events',function(data){_this.actions.setEvents(data);});当我在Chrome中使用源映射调试ES6类并在我调用this.actions

javascript - 递归范围函数不起作用

我正在尝试通过递归地执行范围函数来自学递归。我不明白为什么下面的代码不起作用?迭代版本:functionrangeList(num,num2){vararr=[];for(vari=num;i递归版本:functionrangeRecursive(num,num2){return(num2>num)?rangeRecursive(num2-1).concat(num2):[]}console.log(rangeList(1,7));//returns[1,2,3,4,5,6]console.log(rangeRecursive(1,7));//returns[7]

javascript - ng-if indexOf 与 JSON 数组

我有一个items的JSON输出-要显示单个项目,我使用ng-repeat="iteminitems"。我可以使用user访问当前登录的用户对象每个项目可以属于多个用户的愿望list。如果用户将一个项目添加到他的愿望list中,user_id将保存在item.wishlists中单个item的JSON输出看起来像这样简化了:{"id":1,"title":"Thisisatile","wishlists":[{"user_id":2},{"user_id":3}]}当我执行user.id时,我得到了当前登录用户的ID。现在我想在ng-repeat="iteminitems"中使用ng-

javascript - 打印 json 对象中的所有路径

在给定的Json对象中获取所有路径的简单方法是什么?例如:{app:{profiles:'default'},application:{name:'MasterService',id:'server-master'},server:{protocol:'http',host:'localhost',port:8098,context:null}}我应该能够生成以下对象app.profiles=defaultapplication.name=MasterServiceapplication.id=server-master我能够使用递归函数实现相同的目的。我想知道是否有任何来自json的

javascript - x 的变量在 transit.js 中不起作用

我正在使用transit.js我有以下几行代码:varaxis=Math.floor(Math.random()*2);axis=genXY(axis);if($(this).hasClass(btn_className)){$(this).transition({axis:'100px'},function(){$(this).addClass('active');$(this).transition({axis:0,duration:2000});})}genXY函数如下:varxy=['x','y'];functiongenXY(no){returnxy[no];}现在我在单个元

javascript - 在嵌套的 ng-repeat 中使用带有单选按钮的 ng-model 不起作用

嘿,我正在尝试在ng-repeat中显示单选按钮列表,但它似乎没有接受我在输入中绑定(bind)到ng-model的字段的初始值。当我为ng-repeat提供一个简单的数组时,按钮会正确显示初始值。但是如果出现嵌套的ng-repeat,则只有每个列表的最后一项用一个值初始化这是我的笔:https://codepen.io/alokraop/pen/JXLZBp我不知道我哪里出错了。我确保单选按钮的name属性对于每个组都是唯一的。感谢您的帮助。 最佳答案 这里的问题是您不能将Angular值插入到属性name中。如果我们从HTML中

javascript - 为什么在创建作用域时将参数传递给匿名函数

抱歉,标题很烂,但我想不出更好的了。Polymer中的ShadowDOM.js文件执行此操作:(function(scope){"usestrict";varunsafeUnwrap=scope.unsafeUnwrap;varwrap=scope.wrap;varnonEnumDescriptor={enumerable:false};functionnonEnum(obj,prop){Object.defineProperty(obj,prop,nonEnumDescriptor);}functionNodeList(){this.length=0;nonEnum(this,"le

javascript - 选择焦点上文本输入的所有内容在 Microsoft Edge 中不起作用

在选择输入字段中的所有文本时,我似乎遇到了特定于Edge的问题。我正在使用angular的ng-focus调用Controller中的函数来选择字段中的所有文本。functionselectAllTextOnFocus($event){$event.target.select();}这在除MicrosoftEdge之外的所有浏览器中都可以正常工作,它不会选择输入字段中的文本。我还尝试了另一种jQuery解决方案,除了输入字段的第一个选择外,它仍然有效。之后它会按预期工作并选择所有文本。$('input').on('focus',function(e){$(this).one('mous