How can I use a vendor javascript file inside an exported function?
Here is an example
main.js:
import myfunction from "./myfunctions/myfunction";
my function();
myfunction.js:
export default function myfunction() {
// do something and want to call a function from a vendor file
}
files hierarchy:
main.js
myfunctions/myfunction.js
vendor/color-thief.js
由于当时ColorThief
库未使用module.exports
或类似模块(请参阅https://github.com/lokesh/color-thief/issues/85 ),因此应在html上导入脚本并使用由以下代码公开的全局变量lib window.ColorThief
。
console.log(window.ColorThief)
<script src="https://cdnjs.cloudflare.com/ajax/libs/color-thief/2.0.1/color-thief.min.js"></script>
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.