【问题标题】:Text Field Unknown Props文本字段未知道具
【发布时间】:2018-03-06 00:35:13
【问题描述】:

我尝试下载 Material UI 的示例之一并尝试使用文本字段。示例中的其他组件运行良好(例如对话、按钮)。在 TextField 上,defaultValue 是我尝试过的唯一有效的道具。感谢您的帮助。

我不断收到错误: 警告:标签上的未知道具hintTextfloatingLabelTextfloatingLabelFixed

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


【解决方案1】:

这是使用“版本”:“1.0.0-beta.11”

我切换到最新的稳定版本,一切正常!

【讨论】:

  • 你用的是什么版本的material-ui?
猜你喜欢
  • 2014-01-08
  • 2015-07-23
  • 2013-11-05
  • 1970-01-01
  • 2017-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-06-14
相关资源
最近更新 更多