![](/img/trans.png)
[英]How to import the component in another component which include image in react js
[英]How to import mulitple variables or list from another component in React JS?
我有一个 Profile.js 组件,它使用了一些列表。 该列表很大,因此我想将列表转移到不同的 LabelValue.js 组件并将其导入 Profile.js。 但我不能这样做。 请描述正确的进出口方式。
在 LabelValue.js 中
const bloodGroups = [
{ label: "Choose", value: "" },
{ label: "A+", value: "A+" },
{ label: "B+", value: "B+" },
{ label: "AB+", value: "AB+" },
{ label: "O+", value: "O+" },
{ label: "O-", value: "O-" },
{ label: "A-", value: "A-" },
{ label: "B-", value: "B-" },
{ label: "AB-", value: "AB-" },
];
const genders = [
{ label: "Choose", value: "" },
{ label: "Male", value: "Male" },
{ label: "Female", value: "Female" },
{ label: "Others", value: "Others" },
];
export default { genders, bloodGroups };
在 Profile.js 中
import { bloodGroups, genders } from ".path/to/LabelValue.js"
错误
./src/Pages/Profile.js
Attempted import error: 'bloodGroups' is not exported from '../LabelValue'.
利用
export { genders, bloodGrousps };
不是
export default { genders, bloodGrousps };
默认为单个值
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.