ES6 javascript导入外部js文件 [英] ES6 javascript import external js file

查看:558
本文介绍了ES6 javascript导入外部js文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

 从https://externalutil.com/导入externalutil JS / externalutil.js'; 

但它失败了这个透明错误:

 未找到模块:'https://externalutil.com/js/externalutil.js'

该文件externalutil.js是一个老式的javascript库,不导出任何东西。



任何帮助将不胜感激。

解决方案

您不能导入 URL(至今)。您应该下载该文件,将其放在本地的某个地方,并在本地参考。



然而,在您的情况下,我只需使用 ; script /> 标签将其包含在您的html中,只需访问窗口对象。转换它会比这更有益处。


I'm trying this in my ES6 javascript module:

import externalutil from 'https://externalutil.com/js/externalutil.js';

but it fails with this transpile error:

Module not found: 'https://externalutil.com/js/externalutil.js' 

The file externalutil.js is an old-fashioned javascript library that does not export anything.

Any help will be appreciated.

解决方案

You cannot import URL's (as of yet). You should download the file, put it somewhere locally and reference it locally as well.

However in your case, I'd just use a <script /> tag to include it in your html and just access the window object. Converting it would be more hassle than it would be beneficial.

这篇关于ES6 javascript导入外部js文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆