【发布时间】:2018-03-21 02:20:59
【问题描述】:
我阅读了至少八篇关于标题错误的 Stack Overflow 帖子,但我还没有解决这个问题,因为我将 <>s 中的所有内容都大写并且不使用 HTML 标记。使用 Moment 文档作为指导,我试图在第一个 <Moment></Moment> 中显示一周中的当前日期,并在第二个中显示 2017 年 10 月 9 日这样的日期。下面我粘贴了我的 App.js。我使用 create-react-native 应用程序开始。我应该怎么做?
import React, { Component } from 'react';
import { StyleSheet, Text, View } from 'react-native';
import Moment from 'react-moment';
export default class App extends React.Component {
render() {
return (
<View style={styles.container}>
<Moment format="dddd"></Moment>
<Moment format='MMMM Do YYYY'></Moment>
<Text>Today at a Glance</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
backgroundColor: '#fff',
alignItems: 'center',
justifyContent: 'center',
},
});
【问题讨论】:
-
删除以下行时组件是否呈现?:
<Moment format="dddd"></Moment> <Moment format='MMMM Do YYYY'></Moment> -
你给出了一个格式,但没有给出任何格式的日期。
-
是的 223seneca,当我注释掉组件呈现的那些行时。此外,斯多葛哲学摇滚!
-
我还尝试在 Moment XML 之间传递 {new Date()},bennygenel。顺便说一句好听的名字
-
另外,我尝试了下面的代码,仍然得到这个页面标题中的错误:
标签: react-native momentjs