2014-10-28 36 views
4

在Dart中,我正在開發一款網頁遊戲。在這個我需要一個函數,我可以從URL中獲取數據,就像你用PHP獲得數據一樣。我將如何做到這一點?如何在URL中獲取查詢參數

舉例來說,我在加載我的網頁遊戲時將以下內容附加到我的網址:?id=15&randomNumber=3.14。我如何才能將它們作爲原始字符串(首選)或其他格式?

回答

3

導入'dart:html'那麼你可以使用window.location...

+0

謝謝! 其他人: 位置currentLocation = window.location; print(currentLocation.href); //'http://www.example.com:80/' – CDK 2014-10-28 07:54:27

+0

'位置'是什麼? – 2016-12-01 07:03:15

+0

'dart:html'和'window.location'中的類返回該類的一個實例。 https://dartpad.dartlang.org/79fadf90240c5efd1aeaff80e9187873 – 2016-12-01 07:14:29