typeScript module <a>

/ * Module

   The concept of modules
    Several methods module exports
        1, export export declaration  
        2, export export statement
        3、export default
        4, import import module

    Talking on a modular package DB library

*/

/*
    The concept of the module (official):

         A note on terminology: Be sure to note that, TypeScript 1.5 in terms name has changed. "Internal modules" are now called "namespace."
         "External Modules" is now referred to as a "module" module performs at its own scope, rather than global in scope;
         This means defined in a module of variables, functions, classes, and so outside the module is not visible, unless you explicitly use one of the export form export them. 
         In contrast, when the variable if you want to use other modules exported, functions, classes, interfaces, etc., you have to import them, you can use one of the import form.

    The concept of modules (their understanding of):

        We can put some public functions as a detached single file as a module.
        Module inside the variable functions etc. The default is private, if we want the data (variables, functions, classes) outside the access module inside,
        Inside the module data (variables, functions, classes ...) We need to be exposed through the export.
        We introduce the exposure module can import data using the (variable, function, type, ...) is exposed inside the module.

*/


import { getData,save } from './modules/db';

getData();

save();
var dbUrl='xxxxxx';


export function getData():any[]{

    the console.log ( 'acquired data database 111' );

    return [

        {

            title:'121312'
        },
        {

            title:'121312'
        }
    ]
}



export function save(){

    the console.log ( 'successful save data' );
}

 

Guess you like

Origin www.cnblogs.com/loaderman/p/11040930.html