import语句中的ES6析构函数



有没有写这段代码的方法:

import {o} from 'lib'
let {a, b} = o

作为一个类似于此的内衬:

import {o: {a, b}} from 'lib'

以上语句抛出ES2015 named imports do not destructure. Use another statement for destructuring after the import.

这在let {o: {a, b}} = require('lib')中很容易,但在ES6中似乎不可能,对吗?

不可能,因为它被ECMAscript规范禁止

最新更新