2014-10-28 97 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