提交 732777ca 编写于 作者: fxy060608's avatar fxy060608

fix(ssr): setNavigationBarTitle

上级 549c7f3f
......@@ -9645,8 +9645,10 @@ const getSystemInfoSync = /* @__PURE__ */ defineSyncApi("getSystemInfoSync", ()
});
function updateDocumentTitle(title) {
{
const ctx = vue.useSSRContext();
ctx[uniShared.UNI_SSR_TITLE] = title;
const ssrContext = getApp$1().$.appContext.provides[vue.ssrContextKey];
if (ssrContext) {
ssrContext[uniShared.UNI_SSR_TITLE] = title;
}
}
}
function useDocumentTitle(pageMeta) {
......
import { watchEffect, onActivated, useSSRContext } from 'vue'
import { watchEffect, onActivated, ssrContextKey } from 'vue'
import { UNI_SSR_TITLE } from '@dcloudio/uni-shared'
import { getApp } from '../framework/setup/app'
export function updateDocumentTitle(title: string) {
if (__NODE_JS__) {
const ctx = useSSRContext()
ctx![UNI_SSR_TITLE] = title
// updateDocumentTitle 可能是异步调用,此时使用 useSSRContext 获取,可能没有 instance
const ssrContext = getApp().$.appContext.provides[ssrContextKey]
if (ssrContext) {
ssrContext[UNI_SSR_TITLE] = title
}
} else {
document.title = title
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册