【发布时间】:2019-01-20 16:05:58
【问题描述】:
我是 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"]
};
请帮帮我
【问题讨论】:
标签: arrays reactjs react-redux