小编El.*_*El.的帖子

是否可以使用材料-ui按钮导航与react-router?

我有一个我使用material-UI设计的Web应用程序,我正在使用Button导航来浏览我的基本着陆页组件.

<div className="footer">
  <BottomNavigation value={value} onChange={this.handleChange} className={classes.root}>
    <BottomNavigationAction label="signal" value="signal" icon={<ShowChart />} className={classes.content}/>
    <BottomNavigationAction label="hotlist" value="hotlist" icon={<HotList />} className={classes.content}/>
    <BottomNavigationAction label="analyze" value="analyze" icon={<PieChart />} className={classes.content}/>
    <BottomNavigationAction label="learn" value="learn" icon={<LibraryBooks/>} className={classes.content}/>
    <BottomNavigationAction label="dashboard" value="dashboard" icon={<PermIdentity/>} className={classes.content}/>
  </BottomNavigation>
  </div>
Run Code Online (Sandbox Code Playgroud)

我尝试使用React-Router与这些预先定义的导航组件,但这不起作用,是否有任何可能的方法使用物料UI的按钮导航路由器?material-UI ButtonNavigation API中的按钮导航文章

reactjs react-router material-ui react-router-dom

11
推荐指数
3
解决办法
5955
查看次数

如何设置单选按钮默认选中反应?

我用 3 个单选按钮创建了单选按钮:我想将石灰作为默认选中的单选按钮,我将石灰设置为默认值,但它不起作用。

这是我的代码我不知道如何解决我的问题。

    import React, {Component} from 'react';

    class App extends Component{
      constructor(props){
        super(props)

        this.handleflavorSubmit = this.handleflavorSubmit.bind(this)
        this.onChangeRadio = this.onChangeRadio.bind(this)


        this.state = {value : 'lime'};
        }

      onChangeRadio(e){
        this.setState({value : e.target.value})
      }

      handleflavorSubmit(e){
        alert("your favorite flavor is " + this.state.value)
        e.preventDefault();
      }

      render(){

        return( 
          <div>
            <h1>Choose your flavor:</h1>
            <form onSubmit = {this.handleflavorSubmit}>
              <input type="radio" checked = {this.state.value === 'grapefruit'} onChange = {this.onChangeRadio} value= "grapefruit"/>Grapefruit
              <input type = "radio" checked = {this.state.value === 'lime'} onChange = {this.onChangeRadio} value = "lime"/>Lime
              <input …
Run Code Online (Sandbox Code Playgroud)

html javascript jsx reactjs

5
推荐指数
1
解决办法
7986
查看次数