【问题标题】:ReactJS how to create list "ol" or "ul" with roman number formatReactJS如何使用罗马数字格式创建列表“ol”或“ul”
【发布时间】:2019-01-14 00:22:36
【问题描述】:

我正在创建包含列表的 JSX 元素,我需要使用罗马格式,但没有任何效果

  1. type='i' 未定义
  2. data-type='i' 不起作用
  3. list-style-type="upper-roman" 不起作用

    const howToTest: JSX.Element = (    
      <div>
        <ol list-style-type="upper-roman">
          <li>1</li>
        </ol>
      </div>
    );
    

【问题讨论】:

    标签: html css reactjs flux roman-numerals


    【解决方案1】:

    您不应将list-style-type 作为道具传递,而应作为style 属性传递。

    示例

    class App extends React.Component {
      render() {
        return (
          <div>
            <ol style={{ listStyleType: "upper-roman" }}>
              <li>1</li>
              <li>2</li>
              <li>3</li>
            </ol>
          </div>
        );
      }
    }
    
    ReactDOM.render(<App />, document.getElementById("root"));
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/react/15.1.0/react-dom.min.js"></script>
    
    <div id="root"></div>

    【讨论】:

      猜你喜欢
      • 2018-03-13
      • 1970-01-01
      • 1970-01-01
      • 2011-01-29
      • 2019-05-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-23
      相关资源
      最近更新 更多