如何使用Dart在浏览器中读取cookie?

Ser*_*rov 1 browser dart

问题看起来很简单,但我在文档中找不到如何在没有第三方库的情况下在客户端读取Dart的cookie.

我该怎么做?

stw*_*ton 6

dart:html库中,您可以使用document.cookie.这将返回String所有饼干在客户端上.每个cookie用分号分隔,键值对用a分隔"=".例;

"foo=bar; otherFoo=otherBar"
Run Code Online (Sandbox Code Playgroud)

因此,您可以String根据需要将其拆分为要使用的数据类型.

另见:Document.cookie - Web API | MDN