zoukankan      html  css  js  c++  java
  • 二、安装引入 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;
  • 相关阅读:
    匿名方法
    C# 正则表达式
    c# 预处理命令
    反射
    特性(attribute)
    c# 交换两个变量
    构造函数
    泛型
    Event事件
    委托
  • 原文地址:https://www.cnblogs.com/fger/p/12348425.html
Copyright © 2011-2022 走看看