最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

ecmascript 6 - ES6 javascript import external js file - Stack Overflow

programmeradmin0浏览0评论

I'm trying this in my ES6 javascript module:

import externalutil from '.js';

but it fails with this transpile error:

Module not found: '.js' 

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

Any help will be appreciated.

I'm trying this in my ES6 javascript module:

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

but it fails with this transpile error:

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

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

Any help will be appreciated.

Share Improve this question asked Oct 6, 2016 at 9:42 Nikola SchouNikola Schou 2,4763 gold badges26 silver badges48 bronze badges
Add a ment  | 

1 Answer 1

Reset to default 5

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.

发布评论

评论列表(0)

  1. 暂无评论