React Fragment不适用于Input组件

时间:2018-01-13 03:37:35

标签: javascript reactjs react-native

有没有其他方法可以编写以下代码而无需使用React.Fragment,因为它无效。

          <FormGroup>
            <Input type="select" name="selectMultiPrefs" id="MultiPrefs" multiple>
              {this.state.arrayForCategs.map(function (CategName, index) {
                return (
                   <React.Fragment key={keyNum++}>
                    <option key={keyNum++} value={CategName} disabled>{CategName}</option>
                 {that.props.general.adprefrec.map(function (AdSingle, index) {
                   <option key={keyNum++} value={AdSingle.prefid}>{AdSingle.name}</option>
                 })}
                   </React.Fragment>
                )
              })}
            </Input>
          </FormGroup>

1 个答案:

答案 0 :(得分:1)

这不起作用,因为没有<div class="row"> <?php /** * @package Momentum * Loop custom post type (journal) * @see https://codex.wordpress.org/Post_Types */ /** * Pagination * @see https://stackoverflow.com/questions/41738362/how-to-include-pagination-in-a-wordpress-custom-post-type-query */ $paged = (get_query_var( 'paged' )) ? get_query_var( 'paged' ) : 1; $args = array( 'post_type' => 'journal', 'showposts' => 2, 'posts_per_page' => 2, 'order' => 'DESC', 'paged' => $paged, ); $loop = new WP_Query($args); if ($loop->have_posts()): while ($loop->have_posts()) : $loop->the_post(); ?> <div class="col-lg-6 content"> <div class="article"> <div class="image"> <?php /** * @package Momentum * Check the featured image * @see https://codex.wordpress.org/Post_Thumbnails */ if (has_post_thumbnail()) { the_post_thumbnail( 'full', array('class' => 'img-responsiv') ); }else { ?> <img src="<?php echo get_template_directory_uri(); ?>/assets/img/journal-1.jpg" alt="journal"> <?php } ?> </div> <div class="text-content"> <div class="head-content"> <div class="title"> <h3><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3> </div> <div class="excerpt"> <?php the_excerpt(); ?> </div> </div> <div class="footer"> <a href="<?php the_permalink(); ?>" class="read-more pull-left">READ ENTRY</a> <span class="date pull-right"><?php echo get_the_date(); ?></span> </div> </div> </div> </div><!-- /.col-lg-6 --> <?php endwhile; ?> <?php $total_pages = $loop->max_num_pages; if ($total_pages > 1) { $current_page = max(1, get_query_var( 'paged' )); echo paginate_links( array( 'base' => get_pagenum_link( 1 ) . '%_%', 'format' => 'page/%#%', 'current' => $current_page, 'total' => $total_pages, 'prev_text' => __('PREVIOUS'), 'next_text' => __('NEXT'), ) ); } ?> <?php else: ?> <h1>No Journal found</h1> <?php endif; ?> <?php wp_reset_postdata(); ?> </div>这样的东西。

您想使用<Input type="select">

请参阅https://reactjs.org/docs/forms.html#the-select-tag