mobile development model

1. The traditional development model: This page will write a js, all of the special effects in this inside

  Disadvantages: the coupling is too high, the code correlation too, repairing troubles will cause global pollution.

 

  Too many occurrences request, depending fuzzy, difficult to maintain

2. Modular Development

  (1) Why use a modular?

    Reduce the correlation between code, ease of deployment, better separation, loaded on demand, than avoid naming conflicts, easy to maintain.

  (2) What is modular?

    The modular js file is separated by function, to introduce different files on demand.

    In the front-end development, first appeared in the node.js, common.js in (module.exports and require) with modular web applications in the browser page that requires modular development, early AMD, CMD specification representatives Require.js and sea.js.

    commonjs node is the norm, running on the server, not the browser, if you use the browser, you need to package the file compiled (learn browserify, webpack, gulp, etc.)

    When writing module, the interface exposed to the external module.exports = {} exports.xxx =

    Injection module: require (path)

    Nature commonjs exposure is called a target exports

    module.exports={}和exports.xxx=

    The essence of both is the same, we are exposed to a target exports

  (3) Note: commonjs node is the norm, but he is a synchronous load, synchronous load is a pit in the browser, as long as a link stuck, no hair behind the implementation. It is not recommended, if you want to use to edit package.

Guess you like

Origin www.cnblogs.com/wwwzhaocom/p/10967675.html