【发布时间】:2018-02-05 11:17:50
【问题描述】:
嘿,我正在尝试在我的 url 中为一个简单的 spa 传递两个参数,params 值将使用 api 从 url 中提取并传递给服务器,这里是 url:
http://localhost:8080/#/game/username/token
但是当我点击 url 时,它会在网络中传递这个:
请求网址:http://localhost:8080/api/game/usernametoken
因此它没有命中正确的 api
路由器:
{path:'game/:name/:token', name:'game', component: game }
前端:
this.$http.get('/api/game/'+this.$route.params.name+this.$route.params.token)
服务器端:
app.get('/api/game/:name/:token',function(req,res,err){
var tex = {push:false};
console.log("diplaying token from the server"+req.params.name+req.params.token)
res.end(JSON.stringify(tex));
})
【问题讨论】:
-
请显示一些代码...
-
对不起,我正在编辑和添加代码
标签: parameters vue.js