0

我有一个组件,其中的道具是组件。

Component example:

```jsx
import FavoriteBorder from '@material-ui/icons/FavoriteBorder'
import Favorite from '@material-ui/icons/Favorite'

return (
<Component
  favIcon={{
    icon: FavoriteBorder,
    iconSelected: Favorite,
  }}
/>
)
```

错误

SyntaxError: Cannot use import statement outside a module

如何导入道具

4

1 回答 1

2

事实证明,这;是解决这个问题的关键。

PropertyCardNew 示例:

```jsx
import FavoriteBorder from '@material-ui/icons/FavoriteBorder'
import Favorite from '@material-ui/icons/Favorite'
;<PropertyCardNew
  images={
    [
      {
        url: 'https://www.commerciallistings.cbre.co.uk//resources/fileassets/GB-Plus-480572/09e35192/11%20Strand%201_Photo_1_small.jpg',
        alt: "An Image"
      },
      {
        url: 'https://www.commerciallistings.cbre.co.uk//resources/fileassets/GB-Plus-480572/09e35192/11%20Strand%201_Photo_1_small.jpg',
        alt: "An Image"
      }
    ]
  }
  title="PricewaterhouseCoopers"
  favIcon={{
    icon: FavoriteBorder,
    iconSelected: Favorite,
  }}
  subTitle="4th floor"
  street="313 Stoughton Rd Edgerton, WI 53534-1132"
  date="September"
  desks="20+"
  rent="$5600"
  labels={{
    date: 'date',
    desks: 'desks',
    rent: 'Monthly rent',
    link: 'Details',
  }}
  link="https://commerciallistings.cbre.co.uk"
/>

```

我希望这对某人有所帮助。

于 2020-01-16T19:54:41.680 回答