草庐IT

read_actions

全部标签

javascript - React/Redux 中的通用 reducer / Action

我正在尝试确定如何提取多条数据以在同一组件中使用。我看到的每个React/Redux示例都请求非常具体的数据,并且有reducer和操作来处理该确切类型的数据。但是,我无法找到有关处理更多通用数据的信息。例如,我的网站上有几个不同的组件(或类别)。其中一个组件是Cards。因此,如果用户单击/cards/hockey的链接,它应该从API请求曲棍球数据(如果它不在商店中),并将其显示在Cards页面中。如果用户单击/cards/football的链接,它应该遵循相同的过程,检查它是否有存储的数据,如果没有从API中提取它,并显​​示卡片包含该数据的页面。另一种组件类型可能是stats,

javascript - Mocha 测试 : Uncaught TypeError: Cannot read property 'status' of null

学习TDD和我对“HelloWorld”服务器响应的第一个简单测试在Mocha中失败了。我正在使用Mocha.js、Superagent和Expect.js。当我curl-ilocalhost:8080时,我得到了正确的响应和状态代码。HTTP/1.1200OKContent-Type:text/plainDate:Mon,27Apr201517:55:36GMTConnection:keep-aliveTransfer-Encoding:chunkedHelloWorld测试代码:varrequest=require('superagent');varexpect=require('

javascript - 我应该在哪里放置与 redux 中的 Action 相关的同步副作用?

(注意:我的问题没有写清楚,我在想一些错误的地方。问题的当前版本只是尝试写一些可以使接受的答案对尽可能多的人有用的东西。)我想要一个将项目添加到商店并将其注册到外部依赖项的操作。我可以使用thunk中间件并编写exportfunctionaddItem(item){returndispatch=>{dispatch(_addItemWithoutRegisteringIt(item));externalDependency.register(item);};}但订阅者会在项目注册之前收到通知,他们可能依赖于它是否已注册。我可以颠倒顺序写exportfunctionaddItem(ite

javascript - AngularJS 拦截器类型错误 : Cannot read property 'headers' of undefined

我在尝试实现AJAXSpinner加载代码时由于未知原因收到此错误。我不明白应该在哪里定义header。我做了console.log(config)但我可以看到headers:accept:text/html值。下面是我的代码:/***SpinnerService*///SpinnerConstantsdiary.constant('START_REQUEST','START_REQUEST');diary.constant('END_REQUEST','END_REQUEST');//Registertheinterceptorservicediary.factory('ajaxIn

javascript - 类型错误 : Cannot read property 'push' of undefined, JavaScript

我在这个Angular项目中工作,用户在该项目中提交评论表单,新评论会添加到已发布的评论中。这是我的代码。.controller('productCtrl',function($scope,$http,$routeParams,Page){$scope.product={};$scope.review={};$scope.comments={};routeparm=$routeParams.param;$scope.review=function(){varreview_box=$scope.review_form.review_box;$http.post('./comment.ph

javascript - 使用 map 时 react 'cannot read property of undefined'

我正在从teamtreehouse.com制作一个非常基本的React应用程序,并且我经常遇到"TypeError:Cannotreadproperty'onPlayerScoreChange'ofundefined"即使我正确地绑定(bind)了我的函数(我认为)'onPlayerScoreChange'是Grandparent组件中的一个方法,当用户点击“+”或“-”按钮更改玩家得分时执行。如果有人能解释出什么问题,那将非常有帮助,因为我想我在曾祖parent的构造函数中设置了this.onPlayerScoreChange=this.onPlayerScoreChange.bin

javascript - Angularjs/ ionic 类型错误 : Cannot read property 'then' of undefined

代码:js:angular.module('starter.services',['ngResource']).factory('GetMainMenu',['$http','$q','$cacheFactory',function($http,$q,$cacheFactory){varmethodStr='JSONP';varurlStr='http://localhost/bd/wp-admin/admin-ajax.php';varptStr={action:'bd_get_main_menus',callback:'JSON_CALLBACK'};return{getMainM

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

jQuery(document).ready(function(){//alert("HIQ");$('.mySelectCalendar').datepicker({firstDay:1,dateFormat:"dd.mm.yy"});$.validator.addMethod('date',function(value,element,params){if(this.optional(element)){returntrue;};varresult=false;try{$.datepicker.parseDate('dd.mm.yy',value);result=true;}cat

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

我正在使用nvd3绘制折线图,​​当我将div传递给nvd3绘制图表时,它给我这个错误UncaughtTypeError:Cannotreadproperty'createElementNS'ofundefined代码如下:varchartDiv='line-chart'+counter++;tmpl=$($('#charts-panel-template').clone().html());tmpl.find('.feature-line-chart').attr('id',chartDiv);vardiv=tmpl.find('.feature-line-chart#'+chart

javascript - 为 Angular JS 启用 html 5 模式会抛出 JS 错误 : Failed to instantiate module due to: TypeError: Cannot read property 'html5Mode' of undefined

如何为AngularJS启用html5模式?'usestrict'varblogApp=angular.module('blogApp',['ngRoute']).config(['$routeProvider',function($routeProvider,$locationProvider){$routeProvider.when('/disclaimer',{templateUrl:'templates/disclaimer.html',controller:'DisclaimerCtrl'});$routeProvider.otherwise({redirectTo:'/'}