有什么办法将Dart变量传递到另一个浏览器窗口吗? [英] Is there any way to pass Dart variables to another browser window?
问题描述
我知道我可以使用本地存储,cookies和postMessage,但所有这些方法只接受简单类型。我想直接传递对象和列表到其他窗口。
I know that I can use local storage, cookies and postMessage but all these methods only accept simple types. I want to pass objects and lists directly to the other window.
我发现了一个类似的问题,但使用javascript。我想做一些像Victor指出的链接。
I found a similar question but using javascript. I'd like to do something just like Victor pointed in the following link.
任何类似于Dart的东西在运行之前给我一个警告。
Trying anything similar in Dart gives me a warining even before running.
var popup = window.open('popup.html','');
popup.variable = localVariable; // warning here
var popup = window.open('popup.html', '');
popup.variable = localVariable; //warning here
推荐答案
传递对象是不可能的。
Passing objects is not possible.
您可以序列化为JSON,使其成为一个简单类型,并使用postMessage传递,然后反序列化。
仅包含简单类型的列表和地图应与postMessage一起使用。
You can serialize to JSON to make it a simple type and pass it using postMessage and then deserialize. Lists and maps containing only simple types should work with postMessage.
这篇关于有什么办法将Dart变量传递到另一个浏览器窗口吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!