The wolf is studying "how to find the same color blocks that are connected together ?" Algorithm problems suddenly feel like I need a development mode, or else I feel like my code is messy.
It may be because of studying algorithms, which makes the idea of Wolf very clear. In addition, nodejs and seajs, which have been used for almost a year, are very clear about the cmd api. I will not talk much about it, but look at the code.
Similar to seajs, it conforms to the CMD mode,
VaR require, define; (function () {var module = {} require = function (name) {return module [name]} define = function (name, func) {var exports = module [name] = {} module. exports = exports func (require, exports, module) return exports }})()
Then test
Define ("solve", function (require, exports, module ){
Module. Exports. Name = 21
Module. Exports. Solve = function (){
Console. Log (this. Name)
}
})
Define ("test", function (require, exports, module ){
Require ("solve"). Solve ()
})
Require ("test ")
Finally, the result is successfully output, indicating that the CMD mode can be implemented,