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;
  • 相关阅读:
    PHP中get请求中参数的key不能是para
    js对数组中的数字排序
    js 数组不重复添加元素
    Controllers
    Views
    Models
    Requirements
    Pull Requests
    Upgrade Guide
    Overview & Change Log
  • 原文地址:https://www.cnblogs.com/fger/p/12348425.html
Copyright © 2011-2022 走看看