JS 路由功能
为了优化和提升页面性能,可以使用全局的 JS 路由功能,选择性的在不同页面运行所需的 JS 代码。
使用:
$(document).ready(function(){
var oRouteCustom = {};
// 设置 首页
oRouteCustom['index'] = function(path){
// Index Code
};
// 设置 商品详情 页
oRouteCustom['productDetail'] = function(path){
// Product Detail Code
};
// 初始化
$yhsd.route.init(oRouteCustom);
});
路由名:
| 名称 | 页面 |
|---|---|
| all | 所有页面 |
| index | 首页 |
| cart | 购物车 |
| accountIndex | 个人信息 |
| accountLogin | 登录 |
| accountRegister | 注册 |
| accountRegisterWithEmail | 注册 - 邮箱 |
| accountRegisterWithUsername | 注册 - 用户名 |
| accountRegisterWithMobile | 注册 - 手机号码 |
| accountChangePassword | 修改密码 |
| accountForgetPassword | 忘记密码 |
| accountResetPasswordWithEmail | 忘记密码 - 邮箱 |
| accountResetPasswordWithMobile | 忘记密码 - 手机号码 |
| accountReset | 重设密码 |
| accountValidateEmail | 邮箱注册成功 - 验证邮箱 |
| orderCreate | 创建订单 |
| orderAll | 订单列表 |
| orderDetail | 订单详情 |
| productAll | 所有商品 |
| productDetail | 商品详情 |
| discounts | 参加某个优惠活动的商品列表 |
| types | 拥有某个分类的商品列表 |
| vendors | 拥有某个品牌的商品列表 |
| search | 搜索结果 |
| page | 所有自定义页面 |
| blogAll | 所有博客 |
| blogDetail | 博客详情 |