2017-08-28 84 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) 

你忘了'/'

相關問題