【发布时间】:2018-03-06 00:35:13
【问题描述】:
我尝试下载 Material UI 的示例之一并尝试使用文本字段。示例中的其他组件运行良好(例如对话、按钮)。在 TextField 上,defaultValue 是我尝试过的唯一有效的道具。感谢您的帮助。
我不断收到错误:
警告:标签上的未知道具hintText、floatingLabelText、floatingLabelFixed。
import React, { Component } from 'react';
import PropTypes from 'prop-types';
import TextField from 'material-ui/TextField'
import withStyles from 'material-ui/styles/withStyles';
import withRoot from '../components/withRoot';
const styles = {
root: {
textAlign: 'center',
paddingTop: 200,
},
};
let hint = "I wish this would work.";
class Index extends Component {
render() {
return (
<div>
<TextField
hintText={hint}
floatingLabelText="Floating Label Text"
floatingLabelFixed={true}
/>
</div>
);
}
}
Index.propTypes = {
classes: PropTypes.object.isRequired,
};
export default withRoot(withStyles(styles)(Index));
【问题讨论】:
-
能否也为 withRoot 和 withStyles HOC 添加代码
-
试试看你用的是什么版本的材质ui。他们的测试版有不同的源代码
-
我删除了 withRoot 和 withStyles HOCs 并没有影响问题。
-
来自 Material UI node_module 的 package.json: "version": "1.0.0-beta.11" 也许这就是问题所在 - 我会尝试非 beta。
-
换成稳定版,一切正常!
标签: reactjs textfield material-ui