草庐IT

assign_attributes

全部标签

javascript - 表达 : typescript: Argument of type 'typeof <express.Router>' is not assignable to parameter of type 'RequestHandlerParams'

我将expressjs与最新的typescript定义文件和来自https://github.com/DefinitelyTyped/DefinitelyTyped的typescript2.3.4一起使用.我定义了一个路由器,并希望按照官方4.x文档(app.use('/calendar',router);)中的说明从子路径使用它,但出现以下错误Error:/Users/matthias/Documents/privateworkspace/universal/src/server/server.ts(161,34):Argumentoftype'typeof"/Users/matth

javascript - Sequelize 更新不再起作用 : "Missing where attribute in the options parameter passed to update"

TheofficialAPIdocumentation建议像这样使用Model.update:vargid=...;varuid=...;varvalues={gid:gid};varwhere={uid:uid};myModel.update(values,where).then(function(){//updatecallback});但这给了我:“传递给更新的选项参数中缺少where属性”。文档还提到这种用法已被弃用。看到这个错误让我想,他们已经改变了它。我做错了什么? 最佳答案 显然,文档还没有更新。但是表的where行t

javascript - Angular : src attribute bug in Iframe directive

我在尝试实现Iframe指令时遇到问题。就我而言:模板:指令:angular.module('project.directives',[]).directive('externalIframe',['$rootScope',function($rootScope){return{restrict:'C',replace:true,transclude:true,scope:{src:'@iframeSrc',//thesrcusesthedata-bindingfromtheparentscope},template:'',link:function(scope,elem,attrs)

javascript - JS (ES6) : Filter array based on nested array attributes

我有一个数组,看起来像这样:constpersons=[{name:"Joe",animals:[{species:"dog",name:"Bolt"},{species:"cat",name:"Billy"},]},{name:"Bob",animals:[{species:"dog",name:"Snoopy"}]}];现在我想根据物种进行过滤。例如:每个养猫的人,都应该返回:constresult=[{name:"Joe",animals:[{species:"dog",name:"Bolt"},{species:"cat",name:"Billy"},]}];我试过这样的fil

javascript - typescript : Type 'Promise<{}>' is not assignable to type 'Promise<void>'

我有以下功能:lettemplateLoader=(onDidFinishLoad:Function,onDidFailLoad:Function)=>(url:string):Promise=>newPromise((resolve,reject)=>{mainWindow.loadURL(url);mainWindow.webContents.once('did-finish-load',()=>{onDidFinishLoad(resolve);});mainWindow.webContents.once('did-fail-load',(event,errorCode,erro

javascript - Google Places API 中具有关联 html_attributions 的地点或 place_id(用于测试目的)是什么?

我们正在使用GooglePlacesPlaceDetailsAPI(更具体地说,GoogleMapsJavascriptAPI)。作为使用条款的一部分,我们必须显示响应中html_attributions的值(如果存在)。但是,在尝试测试我们的实现时,我很难找到place的PlacesService.getDetails()响应包含非空值html_属性。PlaceDetailsAPI将为其返回非空html_attributions的示例place_id或地点是否有引用页? 最佳答案 如下所述docs,如果您从google复制任何内容

javascript - typescript 键盘事件 : argument of type 'Event' is not assignable to parameter of type 'KeyboardEvent'

即使代码运行完美,我也会出现以下错误:"TS2345:Argumentoftype'Event'isnotassignabletoparameteroftype'KeyboardEvent'.Property'altKey'ismissingintype'Event'."//InaClasspubliclistenTo=(window:Window)=>{['keydown','keyup'].forEach(eventName=>{window.addEventListener(eventName,e=>{this.handleEvent(e);//{const{key}=event

javascript - CSS 和 JavaScript : Get a list of CSS custom attributes

来自这段代码:HTMLCSS.test{background-color:red;font-size:20px;-custom-data1:value1;-custom-data2:150;-custom-css-information:"loremipsum";}使用javascript——例如从$('.test')——我如何才能得到一个CSS属性列表,其属性名称以前缀“-custom-”开头“?(他们可以有不同的名字,但总是相同的前缀)我想得到这个:{customData1:"value1",customData2:150,customCssInformation:"loremip

javascript - Object.assign 删除现有属性

我可能误解了Object.assign()的工作原理,但我没想到它会删除现有属性,例如:varo1={"status":"","app":{"version":"1.3.1.91","latest_version":"1.3.1.91"}}varo2={"status":"listening","app":{"latest_version":"1.3.2.879"}}console.log(Object.assign({},o1,o2));输出:{"status":"listening","app":{"latest_version":"1.3.2.879"}}我期望的是:{"stat

javascript - JavaScript 中的 Object.assign 和 Object.setPrototypeOf 有什么区别?

假设我有一个具有speak功能的动物对象:functionspeak(){console.log(this.sound)}letanimal={speak}我有一只狗,它会发出声音:letdog={sound:"Woof!"}如果我想让dog从animal继承speak我可以使用Object.assign或对象.setPrototypeOf。它们似乎产生相同的结果:letluke=Object.assign(dog,animal)luke.speak()//Woof!letbruno=Object.setPrototypeOf(dog,animal)bruno.speak()//Woo