ES2015 Module

//export.js

// export class TaskCollection {
//  constructor(tasks = []) {
//      this.tasks = tasks
//  }

//  dump() {
//      console.log(this.tasks);
//  }
// }

// export let foo = 'bar';


// export default class TaskCollection {
//  constructor(tasks = []) {
//      this.tasks = tasks
//  }

//  dump() {
//      console.log(this.tasks);
//  }
// }

// export let foo = 'bar';


export default class TaskCollection {
    constructor(tasks = []) {
        this.tasks = tasks
    }

    dump() {
        console.log(this.tasks);
    }
}



//main.js

// import {TaskCollection, foo} from './TaskCollection';
// import TaskCollection, {foo} from './TaskCollection';
import TaskCollection from './TaskCollection';

new TaskCollection([
    'one',
    'two',
    'three'
]).dump();


你可能感兴趣的:(ES2015 Module)