// webpack
const HsjaTools = require('hsja_tools')
console.log(HsjaTools.isArray([0,1,2]));
// es 全部导入
import HsjaTools from 'hsja_tools'
console.log(HsjaTools.isArray([0,1,2]));
// es 按需导入
import {isArray} from 'hsja_tools'
console.log(isArray([0,1,2]));
<!DOCTYPE html>
<html lang="zh-cn">
<head>
<meta charset="UTF-8">
<title>test测试</title>
<script type="module">
<!--es module 模式-->
import {isArray} from "./dist/hsja-tools.js";
console.log('isArray', isArray([1,2,3]));
// 函数内调用
function getIsArray(value){
import('./dist/hsja-tools.js').then(tools => {
const {isArray} = tools
console.log('getIsArray', isArray(value))
})
}
getIsArray([4,5,6])
// async await 方式
async function getHsjaTools(){
return await import('./dist/hsja-tools.js')
}
const {isNumber} = await getHsjaTools()
console.log('isNumber', isNumber(5))
</script>
<!--umd 格式文件 暴露一个全局变量 HsjaTools-->
<script src="./dist/hsja-tools.umd.cjs"></script>
<script>
console.log(HsjaTools)
console.log(HsjaTools.isArray([11]));
</script>
</head>
<body>
</body>
</html>