85173253 2016-08-09
<html lang="zh-CN"> <header> <meta charset="utf-8"/> </header> <body> <!-- header --> <header> This is header. </header> <!-- main --> <div id="main"> <div class="ui-view"></div> </div> <!-- footer --> <footer> This is footer. </footer> <script src="static/lib/zepto/zepto.min.js" type="text/javascript"></script> <script src="static/lib/vipspa/vipspa.min.js" type="text/javascript"></script> <script src="static/js/index/app.js" type="text/javascript"></script> </body> </html>

$(function() {
vipspa.start({
view: '.ui-view',// 装载视图的dom
router: {
'/home': {
templateUrl: 'static/views/index/home.html',
controller: 'static/js/index/controllers/home.js'
},
'/content': {
templateUrl: 'static/views/index/content.html',
controller: 'static/js/index/controllers/content.js'
},
'/component/:uuid/item/:itemid': {
templateUrl: 'static/views/index/component.html',
controller: 'static/js/index/controllers/component.js'
},
'defaults': '/home'// 不符合上述路由时,默认跳至
},
errorTemplateId: '#error'
});
}); 
<p>home</p>
console.log('This is the page home.'); <p>content</p>
console.log('This is the page content.'); <h3> 这是器件页面 器件的uuid是:<span id="uuid"></span>,id是: <span id="itemid"></span> </h3>
var obj = vipspa.params;// 通过路由传递的参数
$('#uuid').text(obj.uuid);// 由:uuid指定位置的参数
$('#itemid').text(obj.itemid);// 由:itemid指定位置的参数 

