【发布时间】:2021-03-08 13:30:48
【问题描述】:
我有问题。
我创建了 Review.jsx 文件。 我使用 rafce 并编写了代码。 我想将它导入另一个文件,但它写了一个问题。 “评论”不是从“./Review”导出的
在导入的另一个文件代码中 - import { Review } from './Review';
审阅和这个文件在同一个文件夹中
查看.jsx 代码
import React from 'react';
import { Typography, List, ListItem, ListItemText } from '@material-ui/core';
const Review = ({ checkoutToken }) => {
return (
<>
<Typography variant="h6" gutterBottom>Order Summary</Typography>
<List disablePadding>
{checkoutToken.live.line_items.map((product) => (
<ListItem style={{padding: '10px 0' }} key={product.name}>
<ListItemText primary={product.name} secondary={`Quanity: ${product.quanity}`} />
<Typography variant="body2">{product.line_total.formatted_with_symbol}</Typography>
</ListItem>
))}
<ListItem style={{padding: '10px 0' }}>
<ListItemText primary="Total" />
<Typography variant="subtotal" style={{fontWeight: 700}}>
{checkoutToken.live.subtotal.formatted_with_symbol}
</Typography>
</ListItem>
</List>
</>
)
}
export default Review;
【问题讨论】:
-
你能提供一些代码sn-ps吗?也许你的组件和导入行。
-
请添加评论代码
-
需要在
Review.jsx文件中导出Review函数/类组件。您可以执行默认或命名导出。见Export -
这里是评论代码