【javascript – React Native Router Flux动态路由】教程文章相关的互联网学习教程文章

React & Redux & React-Router & Nodejs 实战 crud 项目(18 个视频)

React & Redux & React-Router & Nodejs 实战 crud 项目(18 个视频) React & Redux & React-Router & Node.js 实战 crud 项目 #1 项目搭建「06:22」 React & Redux & React-Router & Node.js 实战 crud 项目 #2 Semantic Ui 和 React-Router「06:26」 React & Redux & React-Router & Node.js 实战 crud 项目 #3 Redux connect「Pro」「04:02」 React & Redux & React-Router & Node.js 实战 crud 项目 #4 发送 ajax 请求「Pro」...

javascript-使react-router不会破坏Jest(reactJs)测试【代码】

我目前正在尝试将Jest测试添加到React应用程序(找到here). 但是,当我运行以下测试时,/** @jsx React.DOM */jest.dontMock('jquery'); jest.dontMock('../js/components/CategoryPage.jsx'); describe('Category Page', function() {var React = require('react/addons');var TestUtils = React.addons.TestUtils;var CategoryPage = require('../js/components/CategoryPage.jsx');it('renders into the page correctly', function...

javascript-React-Router子项不传播【代码】

我正在尝试使用react-router,但无法传播子组件.index.jsimport 'babel-polyfill'; import React from 'react'; import { render } from 'react-dom'; import { Router, Route, browserHistory } from 'react-router';import App from './App';import Login from './containers/Login';const rootElement = document.getElementById('app');render((<Router history={browserHistory}><Route path="/" component={App}><Route path=...

javascript-如何使用react-router创建单页应用程序【代码】

我对React.js很陌生,但是我正在使用它构建一个单页应用程序.对于路由,我正在使用react-router. 我要组织页面的方式如下:我想要一个静态的页眉和页脚(仅加载一次),然后页面的内容将根据路由而变化.这里没什么特别的,这基本上是我对SPA的理解. 这是main.js,它使用以下路线引导我的应用程序:const store = configureStore(); ReactDOM.render( <Provider store={store}><Router history={history}><Route path="/" component={App}>...

javascript-是否可以使用react router将值从子路由传递到其父路由?【代码】

假设我有一个MainHeader和一个标题.使用react router,我将组件渲染到体内.... <header></header> <main>{this.props.children}</main> ...这是我目前的路由器:<Route component={MainLayout} onEnter={requireCordova}><Route path="/home" component={Home} /><Route path="/settings" component={Settings} /> </Route>我的问题是我希望MainLayout从其子项之一中获取标题(以填充标题),这可能吗?<Route component={MainLayout} ...

javascript-未定义的React Router Props【代码】

我在我的Web项目中使用reactjs和react router,但出现错误,这是代码. App.jsimport React from 'react'; import {Router, Route, Link, browserHistory} from 'react-router' import NewuserInfo from './NewUserInfomationComponent'class AppComponent extends React.Component {render() {return (<Router history={browserHistory}><Route path="/new/user/:pid" component={NewuserInfo}></Route></Router>);} }NewUserInfomat...

如何使用在 React Router v4 中以编程的方式进行导航【代码】

1:使用withRouter()高阶函数 withRouter()高阶函数将注入 history 对象作为组件的 prop。该对象提供了push()和replace()方法,以避免使用上下文 import { withRouter } from react-router-dom // this also works with react-router-nativeconst Button = withRouter(({ history }) => (<buttontype=buttononClick={() => { history.push(/new-location) }}>{Click Me!}</button> )) 2:使用<Route>组件和渲染属性模式 <Route>组件...

javascript-React-Router:如果未通过身份验证,则显示主页;如果在“ /”处,则通过身份验证显示仪表板【代码】

如果用户未通过身份验证,我已经将其存储在redux中.我想做的是,一旦我转到localhost:3000 /,如果用户未通过身份验证,我希望它显示主页;如果用户通过身份验证,则希望它显示仪表板.到目前为止,这就是我所拥有的.export default (<Route path="/" component={App} ><IndexRoute component={HomePage} /><Route path="/dashboard" component={Dashboard} /><Route path="*" component={NotFound} /> </Route> );我希望IndexRoute以身份...

javascript-react-router v4:防止使用自定义钩子而不是提示进行过渡【代码】

在react-router v3中,我一直在使用router.setRouteLeaveHook来检查表单是否有未保存的更改,如果是,则返回false以防止过渡.然后,我将显示一个带有3个按钮的自定义引导模式对话框:“保存更改”,“放弃更改”和“停留在这里”. 我无法使用react-router v4的Prompt组件执行此操作,因为无法自定义浏览器确认对话框中显示的按钮.似乎他们放弃了取消过渡的任何方法,而只允许您在浏览器的“确认”对话框中要求用户批准过渡. 我尝试在代码中...

javascript-React-router v4一次显示多个路由【代码】

我遇到一个问题,我使用react-router-dom的路由一次显示所有路由.因此,当我渲染我的App组件和包含“路由”的开始时,我看到的是每个路由的页面彼此重叠.所以看起来像这样:如此一开始,这就是我的index.jsx,它正在页面上呈现App组件:// Dependencies import React from 'react'; import ReactDOM from 'react-dom';// Components import App from './components/app.jsx';// Styles import './index.scss';const container = documen...

javascript-通过React-router渲染子组件【代码】

所以我一直在努力与这段代码.我有一个接受儿童作为道具的组件,它应该是我托管的所有页面的基础. Base.jsx:import React from 'react'; import PropTypes from 'prop-types'; import { Link, NavLink } from 'react-router-dom';const Base = ({ child }) => (<div><div className="top-bar"><div className="top-bar-left"><NavLink to="/">React App</NavLink></div><div className="top-bar-right"><Link to="/login">Log in</L...

javascript-React Router向下滚动新页面【代码】

我在使用react-router ^ 2.4.1时遇到了一个问题,如果我在主页上向下滚动,然后转到新页面,它也将向下滚动,而不是位于顶部(预期行为). 我正在使用这个入门包:react-webpack-node,而我的routes.jsx看起来像这样import React from 'react' import { Route, IndexRoute } from 'react-router' import cookie from 'react-cookie'import App from 'containers/App' import HomePage from 'containers/HomePage' import WaitingListPage ...

javascript-React Router和历史记录【代码】

您好,我真的很新来,我正在看Learncode.academy上的这个很棒的youtube ReactJs教程.本教程来自去年,我不知道这些模块是否已被弃用.我收到以下错误消息:You have provided a history object created with history v4.x or v2.x and earlier. This version of React Router is only compatible with v3 history objects. Please change to history v3.x. at invariant Here is my code:import Layout from "./components/Layout";imp...

javascript-React Router Redux链接更改路由,但未更改组件【代码】

在我的应用程序中,我正在使用"react": "^15.4.2", "react-dom": "^15.4.2", "react-redux": "^5.0.3", "react-router-dom": "^4.0.0", "react-router-redux": "^4.0.8", "redux": "^3.6.0"在我的代码中,我有一个链接(从“ react-router-dom”导入{Link};)<Link to="login">Login</Link>当我单击它时,它正在更改url,同样在redux dev工具中,我可以看到路由路径名正在更改,但是登录路径的组件不可见. 您可以在我的Github存储库中检查...

javascript-如何避免两次重定向(react-router-redux)?【代码】

我正在使用与react-router 4.x兼容的the next (5.0.0) version react-router-redux. 我的应用程序有两个页面/ login和/ home. 如果用户访问的页面不存在,我试图将页面重定向到/ login.这是我的代码import { Route, Redirect } from 'react-router-dom'; import { ConnectedRouter, routerMiddleware, push } from 'react-router-redux';ReactDOM.render(<Provider store={store}><ConnectedRouter history={history}><div><Route p...

ROUTER - 相关标签