Backbone.js BackboneJS如何检测移动页面设置
我有一个具有以下结构的主干应用程序Backbone.js BackboneJS如何检测移动页面设置,backbone.js,Backbone.js,我有一个具有以下结构的主干应用程序 rootfolder - assets - js app - app.js - router.js - config.js modules - all my views in this folder templates - all my html templates here - node_modules - mobilepages (folder with all mobile page
rootfolder
- assets
- js
app
- app.js
- router.js
- config.js
modules
- all my views in this folder
templates
- all my html templates here
- node_modules
- mobilepages (folder with all mobile pages, e.g. mobile BackboneJS setup)
如何检测移动用户并加载mobilepages文件夹?我必须用路由器做这个吗
像这样的
return Backbone.Router.extend({
routes: {
'': 'index'
}
index: function(){
if( /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent))
{
this.navigate("/mobilepages", {replace:true})
};
}
请帮助…如果移动和非移动版本之间没有任何功能差异,那么您可以做两件不同的事情:
routes: function(){
if(!/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|OperaMini/i.test(navigator.userAgent))
{
return {
// routes for mobile devices
};
}
else
{
return {
// routes for non-mobile devices
};
}
}