ES6 export和import

util.js

export let sum  =  (x,y) => {
    return x + y;
}
export let minus = (m,n) => {
    return m - n;
}

main.js

import {num,minus} from './util' 或
import * as util from './util'

console.log(`sum:${sum(1,6)}`) 或 
console.log(`sum:${util.minus(10,6)}`) 

你可能感兴趣的:(ES6 export和import)