diff --git a/packages/runtime-react/src/head/head-manager.ts b/packages/runtime-react/src/head/head-manager.ts index 247cba7f9..4080da6ff 100644 --- a/packages/runtime-react/src/head/head-manager.ts +++ b/packages/runtime-react/src/head/head-manager.ts @@ -44,7 +44,10 @@ export default class HeadManager { private _updateTitle({ attrs }: HeadItem) { const title = attrs.textContent || ''; if (title !== document.title) document.title = title; - assignAttributes(document.getElementsByTagName('title')[0], attrs); + const titleEle = document.getElementsByTagName('title')[0]; + if (titleEle) { + assignAttributes(titleEle, attrs); + } } private _updateElements(type: string, tags: HeadItem[]) {