导入不能在铬61中使用? [英] import can't be used in chrome 61?

查看:114
本文介绍了导入不能在铬61中使用?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在Chrome的最新版本中使用ES6功能,即Chrome 61,并且在使用导入关键字时遇到错误。
从技术上讲, import 用于以下方法,但控制台向我显示了错误:

I'm trying to play ES6 features in the latest release version of chrome, that is chrome 61, and I met the error during using the import key word. Technically, import is used as following method but the console showed me errors:

import Mymodule from "Mymodule.js"

打印控制台:


未捕获的SyntaxError:意外标识符

Uncaught SyntaxError: Unexpected identifier

打开以下实验性功能:

chrome://flags/#enable-javascript-harmony
chrome://flags/#enable-module-scripts

然后关闭:

and following off:

chrome://flags/#disable-javascript-harmony-shipping


推荐答案

问题在于,来自Mymodule.js的

模块必须是完整的URL(包括协议),绝对路径(以/开头)或相对路径(以./或../开头)。

A module must be either a full URL (including a protocol), an absolute path (starting with /), or a relative path (starting with ./ or ../).

其他任何字符串保留供将来使用。

Any other strings are reserved for future use.

来源: https:/ /jakearchibald.com/2017/es-modules-in-browsers/#bare-import-specifiers-arent-currently-supported
(引用自 https://developers.google.com/web/updates/2017/09/nic61#modules

这篇关于导入不能在铬61中使用?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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