将道具传递给组件 - 语法错误
Passing props to a component - syntax error
来自 APP.JS,我正在尝试调用另一个组件 CountryPanel 并向其传递一个参数,但出现语法错误。我做错了什么?
function App(props) {
var countryCode = window.prompt("Enter Country Code")
return (
<div className="App">
{(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}
第 52:62 行:解析错误:意外的标记
50 |
51 |
52 | {(countryCode == "gl") ? : <CountryPanel (countryCode = countryCode) />}}
|
问题就在这里,
{(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}
为什么在这里使用第一个括号,??
<CountryPanel (countryCode = countryCode) />
你大概是这个意思,
<CountryPanel countryCode={countryCode} />
来自 APP.JS,我正在尝试调用另一个组件 CountryPanel 并向其传递一个参数,但出现语法错误。我做错了什么?
function App(props) {
var countryCode = window.prompt("Enter Country Code")
return (
<div className="App">
{(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}
第 52:62 行:解析错误:意外的标记
50 |
51 |
52 | {(countryCode == "gl") ? : <CountryPanel (countryCode = countryCode) />}} |
问题就在这里,
{(countryCode == "gl") ? <InfoPanel /> : <CountryPanel (countryCode = countryCode) />}}
为什么在这里使用第一个括号,??
<CountryPanel (countryCode = countryCode) />
你大概是这个意思,
<CountryPanel countryCode={countryCode} />