我正在使用Javascript的Date()
方法将ISO转换为可读格式。未捕获ReferenceError:localePreference未定义
formatIsoDate({date}) {
const options = { year: 'numeric', month: 'long', day: 'numeric' }
return new Date(dateString).toLocaleDateString(options)
}
render() {
return (
<p>{formatIsoDate({date: this.props.date})}</p>
)
}
,但我得到一个错误:
Uncaught ReferenceError: localePreference is not defined
我读了Mozilla的MDN的文档,但我看不到任何东西在那里。它说toLocaleDateString
区域设置的第一个参数是可选的。
也许我不确定这个代码的环境,但我不认为它是有效的语法。 – jdbiochem
你有一个polyfill的地方吗? –
你可以把更多的代码。你是否在某处使用localePreference –