0%

axios的ES module (esm)

背景
解决
  • 可以用第三方: https://github.com/bundled-es-modules/axios
  • 使用起来很简单, 直接用里面的axios.js即可
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    <!DOCTYPE html>
    <html lang="en">
    <head>
    <meta charset="UTF-8">
    <title>ESM-test</title>
    </head>
    <body>
    <script type="module">
    import axios from './axios.js'

    axios.get('http://127.0.0.1:8888/shuogg').then(resp => {
    console.log(resp.data)
    }).catch(e => {
    console.log(e)
    })
    </script>
    </body>
    </html>