草庐IT

TS-枚举类型enum

全部标签

javascript - Facebook Javascript SDK 未捕获类型错误 : Cannot read property 'userID' of undefined

我正在尝试使用FacebookJavaScriptSDK实现授权功能。当我运行它并检查控制台时,我看到了错误。uncaughtTypeError:Cannotreadproperty'userID'ofundefined代码片段varappId='APP_ID';varuid;//InitializetheJSSDKFB.init({appId:'413026618765431',cookie:true,});//Gettheuser'sUIDFB.getLoginStatus(function(response){uid=response.authResponse.userID?re

javascript - 类型错误 : Cannot read property 'latlng' of undefined

我正在尝试获取鼠标移动时的x,y坐标。我在尝试获取它时遇到错误。TypeError:Cannotreadproperty'latlng'ofundefinedatmouseMove(dashboard:593)atHTMLDivElement.onmousemove(dashboard:442)variMaxZoom=1;varmap=L.map('map',{crs:L.CRS.Simple,minZoom:-5,maxZoom:1});varbounds=[[0,0],[711,473]];varimage=L.imageOverlay('{!!asset('assets/imag

javascript - TypeScript:如何在编译时声明固定大小的数组以进行类型检查

更新:这些检查适用于编译时,而不是运行时。在我的例子中,失败的案例都在编译时被捕获,我期望其他应该失败的案例有类似的行为。假设我正在编写一个类似表的类,我希望该类的所有成员都是相同长度的数组,例如:classMyClass{tableHead:string[3];//expecttobea3elementarrayofstringstableCells:number[3];//expecttobea3elementarrayofnumbers}目前我找到的最接近的解决方案是:classMyClass{tableHead:[string,string,string];tableCells

javascript - 未捕获的类型错误 : Cannot read property '__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED' of undefined

我明白了UncaughtTypeErroroccurs(UncaughtTypeError:Cannotreadproperty'__SECRET_DOM_DO_NOT_USE_OR_YOU_WILL_BE_FIRED'ofundefined)当我使用ReactJS时 最佳答案 抛出错误是因为react-dom找不到React的实例。我想这与您使用res/build/react-min.js而不是res/build/react.min.jsreact-dom中函数名称的荣誉:(function(React){returnReact.

javascript - Typescript 和 jQuery 类型。导入 jquery 类型的正确方法?

是否可以包含jquery.d.ts并使用jQueryStatic类型?我需要类似的东西...protectedel:jQueryStatic;...无论我如何尝试,我都无法从https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/jquery导入jQueryStatic接口(interface)非常感谢。更新///errorTS2304:Cannotfindname'jQuery'.///import{jQuery}from'jquery';errorTS2305:Module'"jquery"'hasnoexpor

javascript - 未捕获的类型错误 : lang is not a function

这个问题在这里已经有了答案:JSfunctionnamed`animate`doesn'tworkinChrome,butworksinIE(3个答案)关闭6年前。在我的HTML中,我在script标签中定义了lang函数并添加了“TestFire!”单击时必须调用lang的按钮:TestingFunctionsfunctionlang(){alert("Hello,World!It'sJavaScriptthistime");}但是,如果我点击按钮,我会得到这个错误:UncaughtTypeError:langisnotafunction但是,如果我将函数名称从lang更改为任何其他

javascript - 类型错误 : scrollIntoView is not a function

我是react-testing-library/jest的新手,正在尝试编写测试以查看路由导航(使用react-router-dom)是否正确执行。到目前为止,我一直在关注README还有这个tutorial关于如何使用。我的一个组件在本地函数中使用了scrollIntoView,这导致测试失败。TypeError:this.messagesEnd.scrollIntoViewisnotafunction45|46|scrollToBottom=()=>{>47|this.messagesEnd.scrollIntoView({behavior:"smooth"});|^48|}49|

javascript - TypeError [ERR_INVALID_ARG_TYPE] : The "original" argument must be of type Function. 接收类型未定义

在下面的代码中,我得到了这个错误:TypeError[ERR_INVALID_ARG_TYPE]:The"original"argumentmustbeoftypeFunction.Receivedtypeundefinedconstsqlite3=require('sqlite3').verbose();constutil=require('util');asyncfunctiongetDB(){returnnewPromise(function(resolve,reject){letdb=newsqlite3.Database('./project.db',(err)=>{if(e

javascript - 以编程方式设置类型为 ="file"的输入 HTML 元素的值?

这个问题在这里已经有了答案:Howtosetfileinputvaluewhendroppingfileonpage?[duplicate](1个回答)关闭5年前。Note:Theanswer(s)belowreflectthestateoflegacybrowsersin2009.Nowyoucanactuallysetthevalueofthefileinputelementdynamically/programaticallyusingJavaScriptin2017.Seetheanswerinthisquestionfordetailsaswellasademo:Howtos

类型化对象的 Javascript 序列化

我不清楚序列化/反序列化应该如何作用于JavaScript中的类型化对象。例如,我有一个包含各种成员和数组的“MapLayer”对象。我已经编写(但尚未测试)以下代码来尝试对其进行序列化:MapLayer.prototype.serialize=function(){varresult="{tileset:tilesets."+tilesets.getTilesetName(this.tileset)+",columns:"+this.columns+",rows:"+this.rows+",offsetX:"+this.offsetX+",offsetY:"+this.offsetY