如何在Chrome/Firefox中导出ES6中的变量
how export variable in ES6 in Chrome/Firefox?
在最新版本的Firefox和Chrome中,我尝试制作导出变量。
index.js:
'use strict'
import { bla } from './helper';
console.log(bla);
helper.js:
export var bla = 20;
但Chrome控制台显示跟随错误消息:
未捕获的语法错误:意外的保留字
firefox控制台显示以下错误消息:SyntaxError:模块尚未实现
从"导入{bla}/helper’<--
我也试着遵循变体index.js:
'use strict'
import { bla } from './helper.js';
console.log(bla);
我也试着遵循变体index.js:
'use strict'
import { bla } from 'helper.js';
console.log(bla);
但是错误消息保持不变。
这在Firefox和Chrome中不受支持。看见https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/import#Browser_compatibility.
你需要某种预处理程序或转译程序来完成这项工作。
相关文章:
- 在ES6中加载SASS变量
- 如何检查ES6“;变量“;是恒定的
- 如何执行“变量”ES6导入
- Javascript ES6共享类变量
- ES6/JavaScript-声明不带let/const的变量
- 如何通过名称(从模块本身)访问ES6模块变量
- NodeJS和ES6类实例中的变量可见性
- ES6 类中成员变量的声明
- ES6 循环和 forEach 中的上下文和变量范围
- 使用参数变量获取传递给 ES6 箭头函数的参数
- 在 $resource.query 回调函数中访问类变量时出现 es6 问题
- Javascript 中的静态变量继承 (ES6)
- ES6/ES2015 对象解构和更改目标变量
- 如何在 es6 类中声明私有变量和私有方法
- 使用 ES6 模块重新导出全局变量
- ES6 块范围的变量定义作为条件
- 在 ES6 中导出多个变量
- 如何在Chrome/Firefox中导出ES6中的变量
- 如何从另一个类(编辑:另一个js页面)访问ReactJS渲染中的变量(ES6和Node正在使用)
- 全局声明的顶级变量(ES6 Babel)