# 快速上手

# npm

全局引入

npm i @wont/utils -S
import utils from '@wont/utils'

utils.getUrlParam(
  'id',
  'http://localhost:8088/#/index?type=hash&id=8080&index=0'
) // 8080

按需引入(推荐)

import { getUrlParam } from '@wont/utils'

getUrlParam('id', 'http://localhost:8088/#/index?type=hash&id=8080&index=0') // 8080

# script

unpkg (opens new window)收录,遵循 umd 规范,不支持tree shaking

<script src="https://unpkg.com/@wont/utils" type="text/javascript"></script>

<script>
  window.onload = function () {
    wontUtils.getUrlParam(
      'id',
      'http://localhost:8088/#/index?type=hash&id=8080&index=0'
    ) // 8080
  }
</script>

# 试一试

打开控制台,wontUtils查看所有方法

wontUtils.getUrlParam(
  'id',
  'http://localhost:8088/#/index?type=hash&id=8080&index=0'
) // 8080
最后更新时间: 10/17/2024, 10:06:15 AM