二、安装引入 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