草庐IT

dynamic-class-loaders

全部标签

javascript - Karma + Jasmine( Angular Testing ): Where should I define mock classes and test variables?

让我们来看下面的例子:constlistDefinition:any={module:"module",service:"service",listname:"listname"};@Component(...)classMockTreeExpanderComponentextendsTreeExpanderComponent{...}classMockListConfigurationsServiceextendsListConfigurationsService{...}describe('ColumnsListConfigurationsComponentTestcases',(

javascript - Vue - webpack vue-loader 配置

每当我想构建一个文件时,我总是收到错误。这是什么原因呢?似乎.vue文件无法被webpack识别,但webpack配置文件看起来正常。网络包错误bundle-app.js189kB1[emitted]app+12hiddenmodulesERRORinUnexpectedtoken>@./app/application.js7:11-31webpack.config.jsvarpath=require("path");module.exports={context:path.join(__dirname,'src'),entry:{app:'./app/application.js'}

javascript - ES6 继承 : uses `super` to access the properties of the parent class

Javascript的super关键字,当我在Chrome、Babel、TypeScript上运行代码时,我得到了不同的结果。我的问题是哪个结果是正确的?规范的哪一部分定义了这种行为?以下代码:classPoint{getX(){console.log(this.x);//C}}classColorPointextendsPoint{constructor(){super();this.x=2;super.x=3;console.log(this.x)//Aconsole.log(super.x)//B}m(){this.getX()}}constcp=newColorPoint();

javascript - Node.js 事件发射器 : How to bind a class context to the event listener and then remove this listener

有没有办法在事件监听器方法中访问类上下文并有可能删除监听器?示例1:import{EventEmitter}from"events";exportdefaultclassEventsExample1{privateemitter:EventEmitter;constructor(privatetext:string){this.emitter=newEventEmitter();this.emitter.addListener("test",this.handleTestEvent);this.emitter.emit("test");}publicdispose(){this.emi

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 - angularjs ng-class 方法被多次调用

在这个例子中,我有2个ng-class,每个调用不同的Controller方法,由于某种原因每个方法被调用3次,知道吗?可能的错误?varnavList=angular.module('navList',[]);navList.controller('navCtrl',['$scope','$location',function($scope,$location){$scope.firstClass=function(){console.log('firstClass');return'labellabel-success';};$scope.secondClass=function(

javascript - 删除 :active pseudo-class from an element

我希望能够告诉一个元素它不再是:active以便CSS规则不再适用。有没有办法在JavaScript中做到这一点? 最佳答案 可能的解决方案:1)使用类:JS:document.getElementById("element").classList.remove("hasactive");CSS:#element.hasactive:active{background:blue;}2)阻止默认的mousedown功能(事件状态):编辑:显然,这只适用于Firefox。JS:document.getElementById("eleme

javascript - Webpack sass loader 无法识别全局变量文件

我有这个sass目录:-_vars.scss-main.scss//变量.scss$base-container:1400px;//main.scss@import'./vars';在我的其他js文件中:require('./some-module-sass-file');//some-module-sass-file.scss.container{width:$base-container;}问题是我在vars文件中有全局变量,而some-module-sass-file无法识别它们并抛出错误:undefinedvariable$base-container

javascript - 除了 First Class Functions 和 Lexical Scoping,JavaScript 与 Scheme 实现有什么共同之处?

我一直想知道为什么DouglasCrockford总是将JavaScript与Scheme进行比较。是的,JS的设计者打算成为Scheme;但是除了一流的函数支持和词法作用域(已损坏)之外,JS与Scheme有哪些共同点使其成为“披着C外衣的Lisp”? 最佳答案 我想到的另一件事是在整个语言和库中普遍使用单一无处不在的数据结构:conslists在Scheme的情况下,maps(在ECMAScript中称为对象。不仅ECMAScript具有一流的过程这一事实,而且这些过程是唯一的抽象机制。(或者更准确地说是封装机制。)

JavaScript "classes"

在这种模式下使用JavaScript“类”有什么缺点吗?varFooClass=function(){varprivate="aprivatevariable";this.public="apublicvariable";varprivatefn=function(){...};this.publicfn=function(){...};};varfoo=newFooClass();foo.public="bar";foo.publicfn(); 最佳答案 你在你的例子中做的不是人们在JS中想到的“类”模式——通常人们会想到更“正常