【问题标题】:React materialize Chips and icons反应物化芯片和图标
【发布时间】:2019-02-02 13:19:28
【问题描述】:

我正在尝试使用 react materialize 设置标签,并且标签组件似乎不会将“关闭”类转移到图标,即使在尝试手动设置之后也是如此。 显示的 html 中的图像:

结果:

标签不可点击。

当我从控制台编辑 html 时,我得到了应有的标签,并且可以点击它:

我的代码是:

import React, { Component } from 'react'
import { Row, Tag, Col, Chip } from 'react-materialize'
class CreatePost extends Component {
render() {
        return (
            <div className="container">
                <form noValidate>
                    <Row>
                        <Col>
                            <Tag className="close">test tag</Tag>
                        </Col>
                    </Row>
                </form>
            </div>
        )
    }

}
<link href="http://fonts.googleapis.com/icon?family=Material+Icons" rel="stylesheet">
 <link href="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/css/materialize.min.css" rel="stylesheet">
 
  <script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/materialize/0.98.0/js/materialize.min.js"></script>
JSON:

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "axios": "^0.18.0",
    "classnames": "^2.2.6",
    "jwt-decode": "^2.2.0",
    "react": "^16.7.0",
    "react-dom": "^16.7.0",
    "react-materialize": "^2.6.0",
    "react-redux": "^6.0.0",
    "react-router-dom": "^4.3.1",
    "react-scripts": "2.1.3",
    "redux": "^4.0.1",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "proxy": "http://localhost:5000",
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

我在这里错过了什么?

【问题讨论】:

    标签: reactjs materialize


    【解决方案1】:

    用芯片试试

    所以 改变

       <Tag className="close">test tag</Tag>
    

       <Chip className="close" close={true}>
           test tag
       </Chip>
    

    【讨论】:

    • 我试过了,没用。作为一种解决方法,我将其更改为 test tag close 并且它有效,但我想知道为什么必须手动
    • 我的答案应该按照他们的文档工作。我也不明白为什么
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-12-18
    • 2022-10-07
    • 2017-12-11
    • 1970-01-01
    • 2020-08-25
    • 1970-01-01
    相关资源
    最近更新 更多