草庐IT

dispatch_main_queue_callback

全部标签

javascript - mapDispatchToProps 与 store.dispatch()

是在组件内部使用mapDispatchToProps来调用Action更有效,还是在Action创建器中使用store.dispatch更有效?mapDispatchToProps示例://ComponentimportReactfrom'React';import{connect}from'react-redux';import{defaultAction}from'./actions';classMyComponentextendsComponent{onClickHandler(){this.props.dispatch(defaultAction());}render(){re

javascript - 如何在 Firefox 插件中从 main.js 调用内容脚本函数

我是Firefox插件开发的新手。我需要一种在Firefox插件中从main.js调用contentscript函数的方法。我在每个打开的网页上都注入(inject)了contentscriptxyz.js。我想通过单击我放置在导航工具栏中的按钮从我的main.js调用我的contentscriptxyz.js中存在的函数abc()。下面是我的代码。主要.js..functionaddToolbarButton(){vardocument=mediator.getMostRecentWindow('navigator:browser').document;varnavBar=docum

javascript - Angular 2 : How to apply a callback when I leave a route

这是例子,我在AppComponent中定义了一些路由:@RouteConfig([{path:'/',name:'Index',component:IndexComponent,useAsDefault:true},{path:'/:id/...',name:'User',component:UserComponent},{path:'/plan',name:'Plan',component:PlanComponent},{path:'/foo',name:'Foo',component:FooComponent}]}在UserComponent中,我定义了另一条路由,如下所示:@R

JavaScript 事件循环 : Queue vs Message Queue vs Event Queue

阅读了大量的JavaScript事件循环教程,我看到了不同的术语来标识队列存储消息,当调用堆栈为空时,事件循环准备好获取消息:队列消息队列事件队列我找不到规范的术语来识别它。甚至MDN似乎也对theEventLooppage感到困惑因为它首先称它为队列,然后是消息队列,但在标签中我看到了事件队列。循环的这一部分是否在某处进行了详细定义,或者它只是一个没有“固定”名称的实现细节? 最佳答案 问得好,我也提倡使用正确的术语。队列、消息队列和事件队列指的是同一个构造(事件循环队列)。此构造具有在事件循环中触发的回调。有趣的是,有两个不同的

javascript - 如何获得 dispatch redux

我正在学习redux和React。我正在学习一些教程,以便制作应用。我有这个Action:exportfunctiongetDueDates(){return{type:'getDueDate',todo}}这是商店:import{createStore}from'redux';importduedatesfrom'./reducers/duedates'exportdefaultcreateStore(duedates)这是reducer:从“不可变”导入不可变exportdefault(state=Immutable.List(['CodeMore!']),action)=>{sw

javascript - react : how to pass arguments to the callback

我的React组件中有一个元素列表,我希望它们是可点击的。单击时我调用一些外部函数在参数中传递项目ID:render(){return({this.props.items.map(item=>({doSomething(item.id)}>))})}此代码有效,但它有一个很大的性能缺陷:每次调用render时都会创建许多新的匿名函数。如何在此处传递doSomething函数作为引用,同时仍然能够为其提供item.id? 最佳答案 您可以使用data-attributes,在使用相同功能的同时为每个项目设置正确的id:function

javascript - 甜蜜警报 : how pass argument to callback

我正在使用javascript警报库sweetalert我的代码是:functionfoo(id){swal({title:"Areyousure?",text:"Youwillnotbeabletorecoverthisimaginaryfile!",type:"warning",showCancelButton:true,confirmButtonColor:"#DD6B55",confirmButtonText:"Yes,deleteit!",closeOnConfirm:false},function(){swal("Deleted!","Yourimaginaryfileha

javascript - 带有 JSONP 的 AJAX 返回错误 Callback is Undefined

这是我的ajax调用。我知道header是正确的,因为当我直接访问url时,它会给我这样的信息:jsonpCallback({"id":"274"})但是当我进行ajax调用时-它说UncaughtReferenceError:jsonpCallbackisnotdefined$.ajax({url:'http://localhost:9000/product/rest/company?'+$('form').serialize(),type:'GET',crossDomain:true,//enablethisdataType:'jsonp',jsonpCallback:'callb

javascript - 无法从单独的模块分派(dispatch)命名空间操作 : [vuex] unknown action type

我有两个模块,activities和alerts。添加activity时,我想使用命名空间操作alerts/SHOW发送警报。当我直接从组件调用操作时(使用来自Vuex的createNamespacedHelpers,带有alerts的命名空间),这会起作用。但是当我从另一个命名空间模块分派(dispatch)操作时,我收到以下错误消息:[vuex]unknownactiontype:SHOW我不确定我做错了什么。我正在为activities命名空间调用ADD操作和另一个createNamespacedHelpers。我还使用了{root:true}选项,在Vuexmoduledocu

javascript - 语法错误 : Unexpected end of input error using Gulp and main-bower-files package

在尝试将主要的Bower文件注入(inject)我的构建文件夹index.html时,我总是遇到错误我正在使用main-bower-filesNPMpackage.我的代码是这样的://requiresvargulp=require('gulp');varinject=require('gulp-inject');varconfig=require('./gulp-config');varmainBowerFiles=require('main-bower-files');gulp.task('default',['move'],function(){returngulp.src(co