在我的專案semantic-version 中,我正在使用 webpack 匯出一個 UMD 包。
<script src="bundles/semVersion.js"></script>在 HTML 檔案中匯入時,有趣的單個類將在SemVersion.SemVersion()( <lib name>.<class name>())下可用。我怎樣才能讓它直接暴露為 SimVersion()?(例如實際上就像 jQuery)。
謝謝!
uj5u.com熱心網友回復:
webpack可以export選擇匯出庫中的任何內容。它可以用于您將類作為默認匯出的情況。
{
output: {
library: {
name: 'SemVersion',
type: 'umd',
// add this to export your class to the library
export: "default"
},
},
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/314044.html
