草庐IT

react-router-dom

全部标签

javascript - 从子组件调用父组件的方法 - React Native

我正在开发我的第一个应用程序,并且仍在学习流程。所以假设我有一个组件叫做:持有方法HelloWorld()的父级,如下例所示:importReact,{Component}from'react';classParentextendsComponent{Helloworld(){console.log('Helloworld');}render(){return({this.props.children})}}module.exports=Parent;然后我想将它导入另一个组件并使用它的方法,那么我该怎么做呢?我会写另一个简短的例子来说明我将如何实现它。importReact,{Com

javascript - 在 React JS 中序列化 <form> 数据提交 POST 请求

我有一个非常基本的评论表单,它接受用户的一些文本输入并通过AJAX发送POST请求以创建新评论。varCommentForm=React.createClass({propTypes:{//...//...},handleFormSubmit:function(e){e.preventDefault();varcomponent=this;return$.ajax({type:"POST",url:this.props.someURL,data://????-Needtofigureouthowtoserializedatahere,dataType:"json",contentTyp

javascript - Angular 2 : Active Router link and routerLinkActiveOptions for dynamically generated links

我有一个使用列表标签创建的菜单我想在其中一个子routerLink像这样使用routerLinkActiveOptions处于事件状态时将一个类应用于父标签Link它工作正常但是当我尝试使用数据数组对动态生成的菜单进行相同的尝试时它不起作用。相同的代码是{{d.name}}如何实现这个,有什么帮助吗? 最佳答案 您需要像设置routerLinkActive="active"一样设置[routerLinkActive]="['linkActive']":{{d.name}} 关于javas

javascript - 在 React 中检查 Prop 类型

我正在阅读React.Component官方React文档中的部分。除了part之外,一切都有意义关于propTypes。文档说明如下:Inproductionmode,propTypeschecksareskippedforefficiency.假设我有以下代码:classSampleextendsReact.Component{render(){return(Hello{this.props.name});}}Sample.propTypes={name:React.PropTypes.string};文档是否暗示在生产中我将跳过针对props的类型检查?如果是,我应该如何检查Pr

javascript - 动画渐变颜色 React Native

我正在尝试在ReactNative中创建一个渐变,该渐变将在应用程序打开时以一种颜色开始,然后每30秒逐渐变为另一种颜色。常规线性渐变在不尝试添加动画的情况下工作。我尝试使用插值和动画计时,如ReactNative文档中所示,但似乎没有任何效果。我的代码:importReact,{Component}from'react';import{processColor,AppRegistry,StyleSheet,Dimensions,Animated,Image,Easing,View}from'react-native';importTimerMixinfrom'react-timer-

javascript - 如何在我的 React 应用程序中使用样式化组件?

我很难命名这个问题,它看起来很宽泛,所以,请原谅我哦版主。我正在尝试styledcomponents第一次尝试将其集成到我的React应用程序中。到目前为止,我有以下内容:importReactfrom'react';importstyledfrom'styled-components';constHeading=styled.h1`background:red;`;classHeadingextendsReact.Component{render(){return({this.props.title});}}exportdefaultHeading;所以,只是一个普通的类,但随后我在

javascript - 如何在 ListView React-native 中过滤数据?

我正在尝试过滤我的数组对象列表,然后尝试使用新数据源在ListView中显示。但是,该列表未被过滤。我知道我的过滤器功能正常工作。(我在console.log里查过了)我正在使用Redux将我的状态映射到prop。然后尝试过滤Prop。这是错误的方法吗?这是我的代码:/*globalfetch:false*/import_from'lodash';importReact,{Component}from'react';import{ListView,TextasNText}from'react-native';import{connect}from'react-redux';import

javascript - React/Redux reducer 在初始化期间返回 undefined

我正在开发我的第一个React/Redux项目。一切顺利,然后我尝试创建一个新的reducer。我认为这是一个非常简单的方法,但是当我加载页面时出现错误“ReducerX在初始化期间返回未定义”。跟踪表明这是在combineReducers()中发生的。我发现了几个类似的问题,但没有解决问题。关于这个问题:WhydoIget“Reducer[...]returnedundefinedduringinitialization”despiteprovidinginitialStatetocreateStore()?问题是他们在createStore()中使用了initialState,而我

javascript - 如何在 React 中缓存图片?

假设我有一个这样的url列表:['/images/1','/images/2',...]我想预取n那些使得图像之间的转换更快。我现在在做什么componentWillMount是以下内容:componentWillMount(){const{props}=this;const{prefetchLimit=1,document=dummyDocument,imgNodes}=props;const{images}=document;consttoPrefecth=take(prefetchLimit,images);constmerged=zip(toPrefecth,imgNodes)

javascript - Vue.js "npm run build"但 Vue.js 未绑定(bind)到 DOM/工作

这里是Vue.js的新手。在MacOS上使用版本:$npm--version4.6.1$vue--version2.8.1我正在使用webpack-simpleinit和vue-cliforvue2.0。我在我的Django项目文件夹中为vue内容创建了一个名为frontend的文件夹。目录结构:$tree├──README.md├──asnew│  ├──__init__.py│  ├──migrations│  ├──models.py│  ├──settings.py│  ├──templates│ └──index.html│  ├──urls.py│  ├──views.py