javascript - ES6 模块中的方法,怎么能彼此调用?
phpcn_u1582
phpcn_u1582 2017-05-19 10:39:01
0
2
472

util/common.js

雷雷
phpcn_u1582
phpcn_u1582

全部回复(2)
滿天的星座

把它当成一个对象, 用this

过去多啦不再A梦
  • common.js

function isEmpty(obj){
    for (var name in obj){
        return false;
    }
    return true;
}
function initUser(){
    isEmpty(obj)
    ...
}
export {isEmpty,initUser}
  • xxx.js

import {isEmpty,initUser} from './common'

而且感觉你的common.js是要作为一个通用脚本吧
直接import './common.js' 就好啊

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板