Use the SPM tool to run the widgets you created (using Common-model to request data from the background interface)

Source: Internet
Author: User

The steps are as follows:

1. Installation Dependence: SPM INSTALL-E

2. Compiling: SPM Build

(The compiled items will be placed in the trunk-dist)

3. Release: SPM app-d

(Will come out an export port, typically: 4745)

4, enter in the browser: http://localhost:4745/examples/index.html can be run

If something goes wrong, it's a bug, and you're done with 2, 3, 4, three steps.

For example:

1, the component structure is as follows:

2. Code: Package.jon configuration information (some dependencies):

"Dependencies": {        "jquery": "<=1.9",        "Backbone": "to",        "Moment": "~",        "Observer": "~0",        "Water-model": "To",        "Lodash": "~",        "Data-list-panel": "~0",        "Water-setting-panel": "~0",        "Base-conditions-filter": "To",        "Moment": "~",        "Jquery-magic-tabs": "~0",        "Common-model": "~0",        "Nunjucks-slim": "To",        "Jquery-jmp3player": "~0",        "Jquery-cookie": "To",        "Excel-export": "~0",        "Store": "To",        "Grid-table-package": "~0",        "Layer": "~"    },

3, Src-sxlcom.js:

//require ('.. /css/sxlcom-theme-base.css ');var$ = require (' jquery ');varBackbone=require (' backbone ');var_ = require (' Lodash ');varCommonmodel = require (' Common-model ')) Module.exports=Backbone. View.extend ({initialize:function(options) { This. options=options | | {};  This. _initoptions (); }, _initoptions:function(){                  //Common-model Instantiation                  //This is the interface inside the Interface_common_model.json.                   varCommonmodel=NewCommonmodel (' Basic.data '); //initiating a requestCommonmodel.fetch ({waterdetails:{params:{ Key:' Select_rain_nodata_list_hn '                           }                      }                  },function(data) {Console.log (data); })//Date Format://[YYYY-MM-DDTHH:MM:SS,YYYY-MM-DDTHH:MM:SS]//[' 2016-12-01t08:00:00,2016-12-01t22:00:00 ']             },    //var Commonmodel = new Commonmodel (' map.layers ');    //Commonmodel.fetch ({    //maplayers: {    //params: {    //Id:area_code,    //type: ' Area '    //         }    //     }    //}, function (data) {    //if (!_.isempty (Data[0].data)) {    //That.options.tileMap.setPolyByData (data[0].data[0].data, That._polyconfig | | {});    //     }    // });Render:function() {}, Dispose:function(){     }});

4, Example-index.html:

<!DOCTYPE HTML><HTML><Head>    <MetaCharSet= "Utf-8">    <title></title></Head><Body><ScriptID= "Seajsnode"src=".. /sea-modules/sea.js "></Script><Scriptsrc=".. /sea-modules/seajs-helper.js "></Script><!--TODO: Other HTML tags -<Script>Seajs.use (['.. /dist/sxlcom-debug'],function(sxlcom) {//TODO Sample Code        Newsxlcom (); });</Script></Body></HTML>

Request Result:

The console prints data from a series of interfaces.

Use the SPM tool to run the widgets you created (using Common-model to request data from the background interface)

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.