typescript调用javascript && URI.js

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转为key=value&key=value...
url=url+'?'+URL.buildQuery(params);
//...
}

猜你喜欢

转载自www.cnblogs.com/Lulus/p/12602890.html