如何删除Backbone.js URL中的# [英] How to remove the # in Backbone.js URL's

查看:88
本文介绍了如何删除Backbone.js URL中的#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Backbone.js的新手,还在学习它,我遇到的一个问题是网上的很多资源已经过时,而且自创建资源以来Backbone.js的情况发生了变化。

I am new to Backbone.js, still learning it and 1 problem I have run into is a lot of resources online are outdated and things have changed in Backbone.js since the time the resources were created.

我感到困惑的是,我看过一些教程很干净的网址,比如这个
domain.com/useer/add 但更多时候我看到 domain.com/#useer/add

What I am confused about is I have seen some tutorials that have nice clean urls like this domain.com/useer/add but more often I am seeing domain.com/#useer/add

所以我的问题是,是吗? Backbone使您可以在不使用的情况下执行此类 domain.com/useer/add 的网址,还是需要其他库?

So my question is, does Backbone enable you to do the URL's like this domain.com/useer/add without the # or does that require another library?

推荐答案

你可以像这样设置pushState = true。

you can set pushState = true like this.

Backbone.history.start({ pushState: true })

看看这个链接了解更多详情。
http:// artsy。 github.io/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/

take a look at this link for more details. http://artsy.github.io/blog/2012/06/25/replacing-hashbang-routes-with-pushstate/

这篇关于如何删除Backbone.js URL中的#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆