【问题标题】:Material UI text input field inside Appbar not workingAppbar内的Material UI文本输入字段不起作用
【发布时间】:2016-12-29 00:20:17
【问题描述】:

我正在尝试使用以下代码在 Appbar 右侧插入用户名和密码的两个文本输入字段。但它没有给出任何输出。

const AppBarExampleIconMenu = () => ( < AppBar title = { < span style = { styles.title } > Test < /span>}
            iconElementLeft = { < IconButton > < NavigationClose / > < /IconButton>}
                iconElementRight = { < div >
                    < TextField
                    hintText = "UserName" / >
                     < TextField
                    hintText = "PassWord" / >
                    < /div>
                }

                />
            );

【问题讨论】:

    标签: node.js material-ui


    【解决方案1】:

    现在试试这个。这是经过测试和证明有效的。请注意,这是用 ES6 风格编写的。

    class Test extends React.Component {
        constructor(props) {
            super(props); 
        }
    
        render() {
            return (
                <MuiThemeProvider>
                    <AppBar
                        title={"Title"}
                        iconElementLeft={<IconButton iconClassName="muidocs-icon-custom-github" />}
                        iconElementRight={
                            <div>
                                <TextField
                                    hintText="Username"
                                />
                                <TextField
                                    hintText="Password"
                                />
                            </div>
                        }
                    />
    
                </MuiThemeProvider>
            )
        }
    }
    

    【讨论】:

    • 为什么到处都是“Mui”。什么是进口声明
    • 对不起。我将 material-ui 导入为 Mui。您可以不使用“Mui”而只使用组件名称。
    • 谢谢@JanFranzPalngipang
    • @Jeril,没问题。
    猜你喜欢
    • 2015-09-26
    • 2017-04-10
    • 1970-01-01
    • 2022-08-05
    • 2020-09-26
    • 1970-01-01
    • 2018-04-02
    • 2019-07-24
    • 2023-03-29
    相关资源
    最近更新 更多