当前位置: 动力学知识库 > 问答 > 编程问答 >

npm - Axios and Webpack

问题描述:

I'm really new to Webpack and I'm using axios with a React project. I installed axios via npm and then I'm importing it like so when I want to use it:

import axios from 'axios/dist/axios.min.js';

Webpack takes care of the rest. Is this the "right" way to do it?

网友答案:

I think the standard way of doing this is as follows:

import axios from 'axios';

The UMD build (axios.min.js) can be helpful when you need to include axios in a <script> tag:

<script src="https://npmcdn.com/axios/dist/axios.min.js"></script>
分享给朋友:
您可能感兴趣的文章:
随机阅读: