https://github.com/excaliburhan/xp-loadjs
动态导入js,支持promise
https://github.com/excaliburhan/xp-loadjs
library
Last synced: over 1 year ago
JSON representation
动态导入js,支持promise
- Host: GitHub
- URL: https://github.com/excaliburhan/xp-loadjs
- Owner: excaliburhan
- Created: 2018-01-31T07:30:58.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2023-01-06T01:57:05.000Z (over 3 years ago)
- Last Synced: 2025-02-19T13:46:36.094Z (over 1 year ago)
- Topics: library
- Language: JavaScript
- Size: 753 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 8
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# xp-loadjs
动态导入js,支持promise
### Usage
```js
import loadjs from 'xp-loadjs'
// single file
loadjs('https://cdn.bootcss.com/jquery/3.3.1/jquery.js')
.then(() => {
console.log('load success')
})
.catch(() => {
console.log('load error')
})
// custom dataset
//
loadjs({
url: 'https://cdn.bootcss.com/jquery/3.3.1/jquery.js',
extraPropMap: {
id: 1
}
})
// multiple files
loadjs(['https://cdn.bootcss.com/jquery/3.3.1/jquery.js', 'https://cdn.bootcss.com/lodash.js/4.17.4/lodash.js'])
.then(() => {
console.log('load success')
})
.catch(() => {
console.log('load error')
})
```