【问题标题】:Unterminated JSX contents in react nativeReact Native 中未终止的 JSX 内容
【发布时间】:2019-12-02 21:58:44
【问题描述】:

我下载了日历模型表单react-native-calendar-select

包装

npm install --save react-native-calendar-select

源代码:

import React, { Component } from 'react';

import ActionButton from 'react-native-action-button';
import Icon from 'react-native-vector-icons/Ionicons';
import { StyleSheet, Text, View } from 'react-native';
import Calendar from 'react-native-calendar-select';


class YourComponent extends Component {
constructor (props) {
  super(props);
  this.state = {
    startDate: new Date(2017, 6, 12),  
    endDate: new Date(2017, 8, 2)
  };
  this.confirmDate = this.confirmDate.bind(this);
  this.openCalendar = this.openCalendar.bind(this);
}
// when confirm button is clicked, an object is conveyed to outer component
// contains following property:
// startDate [Date Object], endDate [Date Object]
// startMoment [Moment Object], endMoment [Moment Object]
confirmDate({startDate, endDate, startMoment, endMoment}) {
  this.setState({
    startDate,
    endDate
  });
}
openCalendar() {
  this.calendar && this.calendar.open();
}
// in render function
render() {
  // It's an optional property, I use this to show the structure of customI18n object.
  let customI18n = {
    'w': ['', 'Mon', 'Tues', 'Wed', 'Thur', 'Fri', 'Sat', 'Sun'],
    'weekday': ['', 'Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday', 'Saturday', 'Sunday'],
    'text': {
      'start': 'Check in',
      'end': 'Check out',
      'date': 'Date',
      'save': 'Confirm',
      'clear': 'Reset'
    },
    'date': 'DD / MM'  // date format
  };
  // optional property, too.
  let color = {
    subColor: '#f0f0f0'
  };
  return (
    <View>
      <Button title="Open Calendar" onPress={this.openCalendar}>
      <Calendar
        i18n="en"
        ref={(calendar) => {this.calendar = calendar;}}
        customI18n={customI18n}
        color={color}
        format="YYYYMMDD"
        minDate="20170510"
        maxDate="20180312"
        startDate={this.state.startDate}
        endDate={this.state.endDate}
        onConfirm={this.confirmDate}
      />
    </View>
  );
}

当我运行它时,我得到了这个错误 这是网站的原始代码,我找不到问题出在哪里

它是一个日历日期选择器,我从npm website复制了原始代码并将代码放在一个类类组件中

请你帮我解决它!

【问题讨论】:

    标签: react-native npm


    【解决方案1】:

    您必须关闭日历上方的&lt;Button&gt;。点赞:&lt;Button title="Open Calendar" onPress={this.openCalendar} /&gt;

    【讨论】:

    • 表示意外令牌 (70:0)
    • Berglonn 但它不知道哪个令牌
    【解决方案2】:

    代码中的按钮标签有一个未终止的标签。试试这个

    <Button title="Open Calendar" onPress={this.openCalendar} />
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2021-04-30
      • 2020-01-10
      • 1970-01-01
      • 1970-01-01
      • 2016-07-17
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多