我是React的新手,在每个组件中,我都通过渲染组件来初始化对象
在所有组件对象都已初始化的情况下,我想将所有整个对象存储在一个文件中。如何存储和导出所有具有不同变量的对象
这是我的示例代码
import React, { Component } from 'react';
import { Link } from 'react-router-dom';
class Footer extends Component {
render() {
const links = {
classname: ["fa-phone", "fa-envelope","fa-location-arrow"],
content: ["Tel:", "Email:","Location:"],
};
return (
<div>
<ul>
{links.classname.map((name, i) =>
<li style={{ listStyleType:"none" }} key={name}> <i className={`fa ${name} text-primary`}></i> <b className="p-lr5">{links.content[i]}</b>{links.subcontent[i]}</li>
)}
</ul>
</div>
);
}
}
export default Footer;
我尝试这样做,如何将对象集合保存在一个文件中
const links1 = {
classname: ["fa-phone", "fa-envelope", "fa-location-arrow"],
content: ["Tel:", "Email:", "Location:"],
subcontent: ["04324-263537", "karurknv@gmail.com", "239, Jawahar Bazaar, karur - 639001"],
};
const links2 = {
links: ["Home", "About Us", "Products", "Gallery", "Services"],
to: ["/", "aboutus", "/products", "/gallery", "/services", "/contact"],
};
const links3 = {
links2: ["/terms&condition", "/privatepolicy", "/contact"],
to2: ["Terms & Condition", "Privacy Policy", "Contact Us"]
};
请帮助我
答案 0 :(得分:0)
使用export
代替export default
。像export const MyComponent
。