util/common.js
//定义一个ES6的模块,对外暴露很多公共的方法
export default {
isEmpty(obj){
for (var name in obj){
return false;
}
return true;
},
isEmptyStr(str){
if(str == null || str == undefined || str == ''){
return true;
}else{
return false;
}
},
initUser(){
//假设这里需要调用同模块中的isEmpty()来进行非空判断,该怎么调用???
},
}
Treat it as an object, use this
common.js
xxx.js
And I feel like your common.js should be used as a universal script
Just do it directly
import './common.js'