Rendering comma separated list of links

后端 未结 10 1573
再見小時候
再見小時候 2020-12-24 00:58

I\'m trying to output a list of comma separated links and this is my solution.

var Item = React.createComponent({
  render: function() {

    var tags = [],
         


        
10条回答
  •  囚心锁ツ
    2020-12-24 01:21

    Or simply write the list items to an unordered list and use CSS.

    var Item = React.createComponent({
      render: function() {
    
        var tags = this.props.item.tags.map(function(i, item) {
          return 
  • }); return ( {this.props.item.name}
      {tags}
    ); } });

    And the CSS:

    .list--tags {
        padding-left: 0;
        text-transform: capitalize;
    }
    
    .list--tags > li {
        display: inline;
    }
    
    .list--tags > li:before {
        content:',\0000a0'; /* Non-breaking space */
    }
    .list--tags > li:first-child:before {
        content: normal;
    }
    

提交回复
热议问题