2017-11-25 186 views
0

有沒有辦法讓Google靜態地圖API鏈接在帕格(玉)模板中動態變化?Google靜態地圖API與玉的動態鏈接

例如,

img.img-responsive.img-rounded(src='http://maps.googleapis.com/maps/api/staticmap?center=52.241770, -0.900181&zoom=17&size=400x350&sensor=true&markers=52.241770, -0.900181&scale=2&key=API_KEY') 

的作品,但

img.img-responsive.img-rounded(src='http://maps.googleapis.com/maps/api/staticmap?center={location.coords.lng},{location.coords.lat}&zoom=17&size=400x350&sensor=true&markers={location.coords.lng},{location.coords.lat}&scale=2&key=API_KEY') 

沒有。

回答

1

如何使用引號?

img.img-responsive.img-rounded(src="http://maps.googleapis.com/maps/api/staticmap?center=" + location.coords.lng + "," + location.coords.lat + "&zoom=17&size=400x350&sensor=true&markers=" + location.coords.lng + "," + location.coords.lat + "&scale=2&key=API_KEY") 
1

試試template literal

img.img-responsive.img-rounded(src=`http://maps.googleapis.com/maps/api/staticmap?center=${location.coords.lng},${location.coords.lat}&zoom=17&size=400x350&sensor=true&markers=${location.coords.lng},${location.coords.lat}&scale=2&key=API_KEY`)