Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/url/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
向URL Meteor Iron路由器添加标题_Url_Meteor_Iron Router - Fatal编程技术网

向URL Meteor Iron路由器添加标题

向URL Meteor Iron路由器添加标题,url,meteor,iron-router,Url,Meteor,Iron Router,目前我有 http://www.example.com/videos/videoId 在我的铁制路由器里 Router.route('/videos/:_id', { name: 'videoShowtemplate' } 我想让我的网站更seo友好,所以我想添加 URL的视频标题 http://www.example.com/videos/videoId/videoTitle 你能告诉我怎么做吗?提前非常感谢。浏览文档: 保持相同的路线,只需将/:slug添加到参数中 在\u id Ro

目前我有

http://www.example.com/videos/videoId
在我的铁制路由器里

Router.route('/videos/:_id', { name: 'videoShowtemplate' }
我想让我的网站更seo友好,所以我想添加 URL的视频标题

http://www.example.com/videos/videoId/videoTitle
你能告诉我怎么做吗?提前非常感谢。

浏览文档:

保持相同的路线,只需将/:slug添加到参数中

\u id

Router.route('/videos/:_id/:slug', { 
    template: 'videoShowtemplate' 
}
使用以下代码重定向到站点

在html中

<a href="/videos/{{_id}}/{{title}}">click here</a>

这么说slug什么也没做?像/videos/videoId/title1和/videos/videoId/title2一样,只要ID相同,就会指向同一个视频?是的,如果你想让slug做些什么,那么在搜索视频时,将slug添加到查询
videos.findOne({u ID:ID,title:slug})仅当两者匹配时才会返回视频
Router.go('videoShowtemplate', {_id: id,slug: title});