搭建react antd

npm install -g antd

npm WARN [email protected] requires a peer of react@>=16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@>=16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN @ant-design/[email protected] requires a peer of [email protected] but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@>=15.x but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@>=15.x but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.1 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.1 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0-0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.0-0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react-dom@^0.14.0 || ^15.0.0-rc || ^16.0.0-rc || ^16.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN [email protected] requires a peer of react@^0.14.3 || ^15.0.0 || ^16.0.0 but none is installed. You must install peer dependencies yourself.

+ [email protected]
added 115 packages in 60.12s

查看react 版本
npm info react

先安装
npm install react-native -g

npm install --save [email protected]
npm install -g react-dom

npm WARN [email protected] requires a peer of react@^16.6.3 but none is installed. You must install peer dependencies yourself.

npm install --save [email protected]

npm WARN [email protected] requires a peer of react@^16.6.3 but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 7 packages and updated 1 package in 179.662s

未安装成功

引入 Can't resolve 'antd/dist/antd.css 报错
Can't resolve 'antd/lib/button' 

App.js

import React, { Component } from 'react';
import logo from './logo.svg';
import Button from 'antd/lib/button';
// import { Button } from 'antd';
import 'antd/dist/antd.css';
import './App.css';


// class App extends Component {
//   render() {
//     return (
//       <div className="App">
//         <Button type="primary">Button</Button>
//       </div>
//     );
//   }
// }



class App extends Component {
  render() {
    return (
      <div className="App">
       <div className="App">
         <Button type="primary">Button</Button>
       </div>


        <header className="App-header">
          <img src={logo} className="App-logo" alt="logo" />
          <p>
            Edit <code>src/App.js</code> and save to reload.
          </p>
          <a
            className="App-link"
            href="https://reactjs.org"
            target="_blank"
            rel="noopener noreferrer"
          >
            Learn React
          </a>
        </header>
      </div>
    );
  }
}

export default App;

猜你喜欢

转载自blog.csdn.net/haogeoyes/article/details/84315536