Angular 16 SSR - 奇怪的缓存响应

问题描述 投票:0回答:1

我已将项目更新到 Angular 16。该项目通过 ngUniversal 使用旧的 SSR 实现。我已在服务器模块中启用了 clientHydration,但现在我在 SSR 响应中收到了这个奇怪的对象列表。我不确定这个对象意味着什么。有办法去掉吗?

"__ɵnghData__": [
                {
                    "t": {
                        "40": "t1",
                        "41": "t2"
                    },
                    "c": {
                        "40": [
                            {
                                "i": "t1",
                                "r": 1
                            }
                        ],
                        "41": [
                        ]
                    }
                },
                {
                    "t": {
                        "0": "t3",
                        "1": "t5"
                    },
                    "c": {
                        "0": [
                            {
                                "i": "t3",
                                "r": 1,
                                "t": {
                                    "1": "t4"
                                },
                                "c": {
                                    "1": [
                                    ]
                                }
                            }
                        ],
                        "1": [
                        ]
                    }
                },
                {
                    "t": {
                        "3": "t8",
                        "4": "t9",
                        "6": "t10",
                        "10": "t11",
                        "11": "t12",
                        "13": "t13",
                        "15": "t14",
                        "17": "t15"
                    },
                    "c": {
                        "3": [
                            {
                                "i": "t8",
                                "r": 1
                            }
                        ],
                        "4": [
                        ],
                        "6": [
                        ],
                        "10": [
                        ],
                        "11": [
                        ],
                        "13": [
                            {
                                "i": "t13",
                                "r": 1,
                                "x": 13
                            }
                        ],
                        "15": [
                        ],
                        "17": [
                        ]
                    }
                },
                {
                    "t": {
                        "3": "t8",
                        "4": "t9",
                        "6": "t10",
                        "10": "t11",
                        "11": "t12",
                        "13": "t13",
                        "15": "t14",
                        "17": "t15"
                    },

我尝试将其删除,但我不确定它是什么。

angular server-side-rendering
1个回答
0
投票

这就是 Angular 用来对服务器端生成的模板进行水合的数据。没有理由删除它。

这是源存储库中的

__nghData__
令牌

/**
 * The name of the key used in the TransferState collection,
 * where hydration information is located.
 */
const TRANSFER_STATE_TOKEN_ID = '__nghData__';

/**
 * Lookup key used to reference DOM hydration data (ngh) in `TransferState`.
 */
export const NGH_DATA_KEY = makeStateKey<Array<SerializedView>>(TRANSFER_STATE_TOKEN_ID);
© www.soinside.com 2019 - 2024. All rights reserved.