1、在public目錄下創建json文件
如:public/api/data.json
2、在json文件中自定義數據
3、當請求url爲'api/data.json'時,會自動去到public目錄下查詢,並返回json內容
代碼示例:
import {SEARCH_BLUR,SEARCH_FOCUS} from './action-type'
import axios from 'axios'
export const searchFocus=()=>({type:SEARCH_FOCUS})
export const searchBlur=()=>({type:SEARCH_BLUR})
export const getList=()=>{
return (dispatch)=>{
axios.get('/api/header.json').then(res=>{
console.log(res.data);
})
}
}