草庐IT

move-constructor

全部标签

javascript - 原型(prototype)继承。 obj->C->B->A,但 obj.constructor 是 A。为什么?

varprint=function(text){document.write(text);document.write("");}varA=function(){}A.prototype.name="A";varB=function(){}B.prototype=newA();B.prototype.name="B";varC=function(){}C.prototype=newB();C.prototype.name="C";obj=newC();print(obj.name);print(obj.constructor.prototype.name);print(obj.cons

javascript - 继承和 TypeScript 错误 : X is not a constructor function type

我有一个父类(superclass),我希望从中继承其他两个类。下面列出了这些类(class)。当我编译时,试图继承的两个类提示父类(superclass)(给出相同的错误):“[类文件路径(在本例中为A)]不是构造函数类型”A.tsexportclassA{//privatefields...constructor(username:string,password:string,firstName:string,lastName:string,accountType:string){//initialisation}}B.tsimportA=require('./A);exportc

javascript - 当 myarray 在一个框架中时,为什么 myarray instanceof Array 和 myarray.constructor === Array 都为 false?

所以下面的代码会发出两次错误警报:window.onload=function(){alert(window.myframe.myarrayinstanceofArray);alert(window.myframe.myarray.constructor===Array);}当页面中有一个名为“myframe”的iframe包含一个名为“myarray”的数组时。如果数组被移动到主页(而不是iframe),那么代码会像预期的那样发出两次true警报。有谁知道这是为什么吗? 最佳答案 functionisArray(o){return

javascript - 谷歌地图 API v3 - TypeError : Result of expression 'google.maps.LatLng' [undefined] is not a constructor

我正在创建一个静态html页面来显示数据中的多个位置。我刚刚复制了其中一个示例并正在向后工作,但我在Safari检查器中收到以下错误:main.js:1SyntaxError:Parseerrorsample.htm:10TypeError:Resultofexpression'google.maps.LatLng'[undefined]isnotaconstructor.这是我的html代码:MultiMarkersSampleviaGoogleMapsfunctioninitialize(){varmyLatlng=newgoogle.maps.LatLng(-30.2965590

javascript - 为什么 jslint 更喜欢 {}.constructor(obj) 而不是 Object(obj)

两者都将检测对象而不是基元。这似乎是纯粹的句法差异。//jslintprefers{}.constructor(obj)overObject(obj)//calledisObjectbyunderscore//willtestonlyforobjectsthathavewritablekeys//forexamplestringliteralswillnotbedetected//butarrayswillvarisWritable=function(obj){return{}.constructor(obj)===obj;}; 最佳答案

javascript - Angular.js 和 Fabric.js : Fabric canvas changes behavior once code is moved to a Angular Directive

我有一个简单的AngularJS/FabricJs应用程序,目的是允许在上传之前移动/重新调整图像大小。基本上有四个步骤:1)Ipresentaformwithacanvas,andarectangleinsideofformtorepresentacliparea2)browseforalocalfile3)addittothecanvas4)andhaveabuttontocapturetheclipareainsideofthecanvas当我将代码从直接嵌入的形式移动到位于AngularDirective(指令)后面时,就会出现问题。一旦我将表单移动到指令中,就会弹出一个问题,

javascript - "Class extends value #<Object> is not a constructor or null"

感谢阅读我的文章我的代码出现此错误:“Classextendsvalue#isnotaconstructorornull”这是我的代码,我正在尝试导出/导入类。怪物.js:constminiMonster=require("./minimonster.js");classmonster{constructor(options={name},health){this.options=options;this.health=100;this.heal=()=>{return(this.health+=10);};}}letbigMonster=newmonster("Godzilla");

javascript - RXJS : moving from of() to scheduled()

我使用of()运算符来创建具有简单值的可观察对象,例如of(navigator.onLine)但我不得不更新RxJS版本,我得到了这个linter警告ofisdeprecated,改用scheduled。这显然不是完全相同的功能,我不应该设置调度程序。你会如何对待它?感谢任何帮助。谢谢。 最佳答案 这个是是一个rxjsbug,它是stillopenclosed。检查here了解更多信息您可以监控此问题并同时使用://tslint:disable-next-line:deprecationof(navigator.onLine);

javascript - HTML5 Canvas : Moving/panning world with arrow keys in EaselJS

经过一年的学习和反复试验,我觉得我开始对JavaScript有了更多的了解。所以,现在,我想尝试编写一个简单的2D平台游戏(想想《super马里奥世界》或《刺猬索尼克》)。为此,我将使用EaselJS库。我想弄清楚如何使用左右箭头键在Canvas中移动/平移“世界”。我知道如何在箭头键的keydown上运行函数,但我不太确定应该如何处理移动/平移。当按下一个键时,我是否应该调整Canvas中每一个东西的位置/坐标?或者我是否应该将所有东西都放在一个容器中并移动容器的位置/坐标?我会感激任何能将我推向正确方向的东西。泰夫姆:)更新了答案Thechosenanswerbelow确认我确实必

javascript - Photoshop 脚本 : Move an image to position x, y

我有一个事件的ArtLayer被变量NewLayer引用,我想移动到Canvas中的绝对位置x,y。我已经用谷歌搜索了几个小时,但没有任何结果。有人可以举个例子吗?//谢谢。 最佳答案 经过更多API阅读和搜索后,我得出的结论是只能使用增量移动来移动图层。我编写了这个小函数来将图层定位在绝对位置。希望这对下一个有同样问题的读者有所帮助...//******************************************//MOVELAYERTO//Author:MaxKielland////MoveslayerfLayert