草庐IT

this_is_not_a_task

全部标签

javascript - $timeout 函数中的 AngularJS 'this' 引用不起作用

我有一个让我发疯的AngularJS问题。我有一个看起来像这样的服务(这是一个说明问题的例子)varapp=angular.module('test-module');app.service('ToolService',function($timeout){this.doSomething=function(){console.log("yunoreferencedasmethod?!?");}this.runTimeoutExample=function(){$timeout(function(){this.doSomething();},1000);}})我的Controller看

javascript - this.props.history 已弃用( react 路由器)

我试图以编程方式导航到另一个页面,就像这样this.props.history.push('/new-path');它有效,但我在控制台中收到弃用警告说:警告:[react-router]props.history和context.history已弃用。请使用context.router。此处有更多信息https://github.com/reactjs/react-router/blob/master/upgrade-guides/v2.0.0.md#changes-to-thiscontext之后我尝试像这样使用这个新方法this.context.router.push('/new

javascript - 在 TSX 文件 : Property 'createRef' does not exist on type 'typeof React'

我需要组件的引用。刚刚从jsx转移到tsx并找不到解决这个问题的方法。其他解决方法是使用查询选择器,但我认为这不是做react的好方法。这里是构造函数constructor(props){super(props);this.state={data:initialData,showNewListForm:false,whichButtonClicked:undefined,background:props.background||"#23719f"};this.divContainerRef=React.createRef();console.log("kanbanreference:"

javascript - 为什么 *this* 不是 *this*?

我刚刚写了这段代码来表示这个让我丧命的错误(Grrr!)我想知道为什么当我得到error:methodundefined时,我已经在Safari中检查过,parserDidStart()方法中的这个变量不是EpisodeController类型,而是EpisodeFeedParser类型,这是为什么?varEpisodeFeedParser=function(url){this.url=url;this.didStartCallback=null;};EpisodeFeedParser.prototype.parse=function(doc){this.didStartCallbac

javascript - 如何使用带有 "this"的 javascript 提交表单

有什么方法可以提交我有这样的href链接的当前表单Save我想在任何地方都使用相同的代码,所以我不能使用任何id或类 最佳答案 使用this.form.submit()提交表单即在你的情况下它会像Save但强烈建议使用表单名称否则,如果您习惯使用jquery,您也可以使用jqueryclosest功能$(field).closest("form").submit(); 关于javascript-如何使用带有"this"的javascript提交表单,我们在StackOverflow上找到

javascript - 路由中的 Ember "Params is not defined"

我是ember的新手,正在构建一个非常简单的应用程序。我可以通过单击链接到标记生成的链接,从我的育种者索引页面(/breeders)导航到我的育种者显示页面(/breeders/:breeder_id)。但是,如果我手动导航到breeders/1或任何其他breeders.show路线,我会收到以下错误:Errorwhileloadingroute:ReferenceError:paramsisnotdefinedatCatapp.BreedersShowRoute.Ember.Route.extend.model我不知道我做了什么导致了这个。这是我认为的相关代码://router.j

javascript - 解决 Node.js 中的 "Uncaught ReferenceError: require is not defined"错误

我正在尝试使用SengGrid设置一个基本的联系表单,但我不断收到“UncaughtReferenceError:未定义要求”的错误。我在html页面头部的脚本标记中有这段代码。varsendgrid=require('sendgrid')(username,pass);我看过requirejs,但不确定为什么会出现此错误。有人可以向我解释如何解决这个问题吗? 最佳答案 require()未内置于浏览器中。所以当您说“我在html页面头部的脚本标记中有这段代码”。这可以解释为什么在脚本运行时undefinedsymbolrequir

javascript - 如何解决错误 "Did not load script at ' 脚本名称',因为在给出 'X-Content-Type: nosniff' 时不允许使用非脚本 MIME 类型

我有一个相当简单的Angular1.x应用程序,在我升级到Safari11之前它运行良好。现在,它不起作用,因为几乎所有的js文件都被阻止了。CSS文件也是如此,但删除“rel”属性并添加type="text/css"解决了CSS问题。对于JS文件,我确保将type="text/javascript"添加到脚本标签中。我也只是尝试将./添加到src的开头以获取笑声,但它们仍然无法加载。有人知道如何解决这个问题吗?谢谢,韦恩 最佳答案 我只想删除这个问题,但我希望这个答案可能对某些人仍然有帮助。所以,我的问题实际上是我的项目克隆不好,

javascript - 未处理的 promise 拒绝警告 : This error originated either by throwing inside of an async function without a catch block

我的Node-Express应用出现以下错误UnhandledPromiseRejectionWarning:Unhandledpromiserejection.Thiserrororiginatedeitherbythrowinginsideofanasyncfunctionwithoutacatchblock,orbyrejectingapromisewhichwasnothandledwith.catch().(rejectionid:4)至少可以说,我创建了一个看起来像这样的辅助函数constgetEmails=(userID,targettedEndpoint,headerA

javascript - this.name 在 javascript 中返回 undefined

我正在尝试远程创建一个onclick对于每个(以节省打字时间)。这是window.onload()功能:window.onload=function(){divel=document.getElementsByTagName('div');for(varelindivel){divel[el].onmouseover=function(){this.style.textDecoration="underline";};divel[el].onmouseout=function(){this.style.textDecoration="none";};divel[el].onclick=