二、安裝引入 antd


一、環境依賴版本

1、npm安裝yarn

npm install -g yarn 

查看版本:

yarn --version

 安裝axios

npm install axios --save-dev

 

二、腳手架搭建以及在項目中引用antd插件

 三、請求數據

代碼如下:

import React from 'react';
import { Link } from 'react-router-dom';
import { Button } from 'antd';
import Axios from 'axios';

function Login() {
  return (
    <div>
      Login頁面
        <ul>
        <li><Link to="/">顯示1</Link></li>
        <li><Link to="/home">顯示2</Link></li>
      </ul>
      <Button onClick={Fromclick} type="primary">Button</Button>
    </div>
  );
}

function Fromclick() {
  //發送請求
  Axios.get("http://wthrcdn.etouch.cn/weather_mini?citykey=101010100")
    .then(res => {
      console.log("請求成功:", res.data);
    })
    .catch(err => {
      window.console.log('請求失敗:', err);
    })

}

export default Login;

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM