2017-08-28 54 views
1

嘿,我想在我的网址传递两个参数为一个简单的SPA和params值将从URL中使用api提取并传递到服务器这里的URL :如何在URL中传递多个参数时使用vuejs

http://localhost:8080/#/game/username/token

,但是当我打它通过这个网络中的URL:

请求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)); 

}) 
+0

显示一些代码,请... –

+0

不好意思,我正在编辑和添加代码 –

回答

2

你的GET请求应该是

this.$http.get('/api/game/'+this.$route.params.name + '/' + this.$route.params.token) 

你忘了'/'

相关问题