[英]Is it possible to deconstruct imports on babel 7?
使用babel 7,您將無法再真正使用babel語法導出模塊並對其進行解構。 是否有插件,舊語法或我缺少的東西可以執行以下操作?
// file1.js
export const x = 0;
export const y = 1;
export default z;
// file2.js
import { x, y } from './file1.js'
console.log(x); // output: 0
console.log(y); // output: 1
好的,在Felix的幫助下,我設法解決了問題。 我的誤解非常愚蠢: export
仍會聲明您在其后定義的任何變量,例如:
const x = 0;
export const x = 0; // this will be invalid, because x is a constant already
我一直在Webpack上收到語法錯誤,並且不明白這是因為我兩次聲明了變量,所以我認為這是Webpack或babel的問題。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.