字典中的 Nonce shorthand 在 Explorer 上导致 script1003 错误

Nonce shorthand in dictionary causing script1003 error on Explorer

我正在使用带有 AWS cognito 的随机数来保存状态。我遵循了 Medium article

中的一个示例
const nonce = auth.generateRandomString(auth.getCognitoConstants().STATELENGTH, auth.getCognitoConstants().STATEORIGINSTRING);
const state = {
    deepLink: window.location.href,
    nonce
};
console.log(state);

看起来 'nonce' 可以用作键值对的 shorthand,如下所示的控制台日志,虽然我不完全理解 shorthand 部分.

> deepLink:"https://example.com/mydeeplinkedpage.html"
> nonce: "iva3EtWzAZ92URHi9uXM6oqIEaagGOPO"

这导致资源管理器中出现“script1003: expected ':'”错误,我猜是因为它期望冒号跟在 'nonce' 键之后'state'字典。

有没有在字典中包含随机数的长手,这样资源管理器就不会爆炸? 'nonce' 是唯一可以在这样的字典中使用速记的东西吗?

其他人简短地留下了一个答案,但由于某种原因不再存在,所以我不能将这个答案归因于他们。等效的普通方式如下,在 IE 中不会爆炸:

const state = {
    deepLink: window.location.href,
    nonce: nonce
};

根据评论中的@Bravo,随机数的 shorthand 并不特定于随机数。