[英]javascript es6 import symbols into a namespace
是否可以從 ES6 javascript 模塊導入特定符號,但仍導入命名空間? 我正在尋找以下組合: import * as d3 from 'd3'
將導入的符號放入 d3 命名空間,並import {select, selectAll} from 'd3-selection'
避免導入所有內容。 理想情況下,我想要這樣的東西:
import {select, selectAll} as d3 from 'd3-selection'
d3.select(...)
d3.selectAll(...)
可能嗎? 我想在我的代碼中保留d3.function
的常用代碼語法,但也只導入我需要的符號。
您可以在兩行代碼中執行該操作
import {select, selectAll} from 'd3-selection';
const d3 = {select, selectAll};
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.