草庐IT

not_null

全部标签

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 - 使用 express nodejs 获取此错误 auth/operation-not-supported-in-this-environment

我在我的项目中使用Firebase,但在使用google凭据登录时出现此错误auth/operation-not-supported-in-this-environment。.hbs文件代码脚本代码functionloginWithGoogle(event){$.ajax({url:"/session/google/login",type:"POST"}).done(function(data){error=JSON.stringify(data);console.log(error);M.toast({html:error})});}express代码router.post('/se

javascript - Uncaught ReferenceError : Worker is not defined while trying to create a Worker within another Worker in Chrome

这link说:Workersmayspawnmoreworkersiftheywish.So-calledsub-workersmustbehostedwithinthesameoriginastheparentpage.Also,theURIsforsubworkersareresolvedrelativetotheparentworker'slocationratherthanthatoftheowningpage.Thismakesiteasierforworkerstokeeptrackofwheretheirdependenciesare.但是当我尝试在另一个Worker中创

javascript - React 警告传递的值为 null 的 prop,其中不需要 prop 的 PropType

我有一个组件接收error作为字符串或具有2个必需属性的对象。但是null也可以为这个Prop传递。在我当前的设置中,当传递null时,React会发出警告:Warning:Failedproptype:InvalidproperrorsuppliedtoErrorDialog我应该为React更改什么以允许null|字符串|具有这种形状的物体?谢谢!ErrorDialog.propTypes={onResetError:PropTypes.func.isRequired,error:PropTypes.oneOfType([PropTypes.shape({id:PropTypes.

JavaScript - window.scroll({ 行为 : 'smooth' }) not working in Safari

正如标题所说,它在Chrome上运行得非常好。但在Safari中,它只是将页面设置到所需的顶部和左侧位置。这是预期的行为吗?有没有办法让它很好地工作? 最佳答案 使用smootscrollpolyfill(适用于所有浏览器的解决方案),简单适用且轻量级依赖:https://github.com/iamdustan/smoothscroll通过npm或yarn安装后,将其添加到您的ma​​in.js、.ts文件(第一个执行的文件)importsmoothscrollfrom'smoothscroll-polyfill';//orifl

javascript - 如何避免 Jest 警告 : A "describe" callback must not return a value?

将Jest从版本23升级到版本24后,在运行我的测试时,几乎每个测试都会收到这样的警告消息:A"describe"callbackmustnotreturnavalue.Returningavaluefrom"describe"willfailthetestinafutureversionofJest.附带的堆栈跟踪指向此模块:addSpecsToSuite(node_modules/jest-jasmine2/build/jasmine/Env.js:443:15)这样做的原因是我喜欢在我的测试中使用箭头函数的简写版本,当函数体只包含一个语句时省略大括号,例如:describe('t

javascript - 为什么使用 "!= null"测试参数是否传递不好

这个问题在这里已经有了答案:Detectinganundefinedobjectproperty(50个答案)关闭9年前。从MaintainableJavaScript一书中提到://Bad:TestingtoseeifanargumentwaspassedfunctiondoSomething(arg1,arg2,arg3,arg4){if(arg4!=null){doSomethingElse();}}但我觉得这里用!=null还是挺有效的,它过滤了参数未传递和传递为null的情况作者认为它不好的原因是什么?

javascript - Chrome : not "remembering" the choice to allow access to microphone

我有一个super简单的网页,它使用WebSpeechAPI这样我就可以更轻松地与我妈妈(她是聋子)交流。Google的语音识别速度足够快,我可以与她实时交谈(她会读取虚拟现实结果)。我的网站:http://goo.gl/Wm69Mp我们都在使用Chromev30.0.1599.66。我遇到的问题是,每次我点击麦克风图标时,Chrome都会询问我是否允许访问。我每次都点击“允许”。如果我查看我网站的Chrome媒体设置,我发现音频行为设置为“询问”,但我似乎无法将其更改为“允许”。有人知道这里发生了什么吗?更新看起来我可能必须启用https才能记住我的选择。如果可能的话,我仍然希望有人

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 - 未捕获的类型错误 : 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更改为任何其他