当前位置: 首页 > 工具软件 > URI.js > 使用案例 >

typescript调用javascript && URI.js

东郭宏朗
2023-12-01

URI.js

URI.js是一个用于处理URL的JavaScript库
它提供了一个“jQuery风格”的API(Fluent接口,方法链接)来读写所有常规组件和许多便利方法,如.directory()和.authority()
本文以URI.js库为例进行讲解
链接:
http://medialize.github.io/URI.js/
https://github.com/medialize/URI.js

ts使用js

安装URI.js

npm install urijs

配置tsconfig.json

{
  "compilerOptions": {
    // 允许调用js
    "allowJs": true } }

使用js

import * as URL from 'urijs' // get请求 getRequest(url: string, params: any): Promise<any> { //...  //把any转为key=value&key=value...  url=url+'?'+URL.buildQuery(params); //... }

转载于:https://www.cnblogs.com/Lulus/p/8549784.html

 类似资料: