请花些时间COMPLETELY读物在提问前打标或应答text url参数如何工作?
我想在URL,并使用相同的访问它来显示从数据文本。例如。
http://stackoverflow.com/questions/24888693/how-does-out-parameter-work
声明本页面是如何利用目前我使用requireJs
在我的web应用程序backboneJs
帕拉姆how-does-out-parameter-work
访问。所以,在我的路由器我很喜欢路由
siteTitle = 'Boiler Plate';
define([
'jquery',
'underscore',
'backbone',
'handlebars',
'jcookie',
'views/home',
'views/404'
], function ($, _, Backbone, Handlebars, jcookie, HomePage, FoFPage) {
var AppRouter = Backbone.Router.extend({
routes: {
':*':'home',
'home' : 'home',
'home/:a' : 'home',
'*whatever' : '404'
},
home: function (a) {
document.title = siteTitle + ' - Home';
homePage = new HomePage({route: a});
homePage.render();
},
404: function(){
document.title = siteTitle + ' - 404';
fofPage = new FoFPage;
fofPage.render();
}
});
var initialize = function() {
var app_router = new AppRouter;
Backbone.history.start();
};
return {
initialize: initialize,
AppRouter: AppRouter
}
});
请注意,我得到传递的参数a
并据此加载页面。目前,我正在将该参数a
设置为我的帖子ID并相应地使用它。如果我想传递我的文章标题的一部分并访问它,我该怎么做?
我能想到的一个办法是选择从MySQL数据库字符串和基于URL输入,但它不会有所帮助,如果该参数是how-does-out-parameter-work
我永远不能解析它为How does 'out' (parameter) work?
这是在数据库中的实际文本。我错过了什么?
UPDATE
的忽略后一个参数是只适用于stackvoerflow不得在本网站 https://www.theguardian.com/us-news/2016/nov/10/hate-crime-spike-us-donald-trump-president
使用别的东西。我错过了什么?
实际上'how-does-out-parameter-work'被忽略。这只是做一个漂亮的网址。实际上,您可以通过将其保留在相同的页面。 - >例如。 http://stackoverflow.com/questions/24888693 IOW:这是重要的数字部分.. – Keith
我假设他们会有一个类似'us-news /:year /:month /:day /:heading'的路线,他们会有一个databse函数,像 - >'getDoc(年,月,日,标题)' – Keith
@ Keith OK!那是我的问题!他们如何解析'getDoc(年,月,日,标题)'。因为如果标题中有括号或特殊字符,则不会在url中显示。 '如果参数是怎么做 - 参数工作,我永远不能解析它如何'出'(参数)的工作?这是数据库中的实际文字' – unkn0wn