react路由傳參獲取後臺資料
阿新 • • 發佈:2019-02-11
前期準備工作:
1. npm install axios (axios 用來獲取資料用) 下載完成後可以console.log(axios); 驗證是否下載成功
2. data.js (模擬後臺資料,相當於後臺介面)
import React, { Component } from 'react';import { BrowserRouter as Router, Route, Link } from 'react-router-dom';import axios from 'axios';import Data from './data.js';class Article extends
export default App;
data.js
const objContent = [{ id: '1', content: '001'},{ id: '2', content: '002'},{ id: '3', content: '003'}];console.log(objContent);