@antdv/pro-utils
Version:
@antdv/pro-utils
20 lines (19 loc) • 513 B
JavaScript
import { computed, watch } from "vue";
import { isBrowser } from "../../is/index.mjs";
function useDocumentTitle(titleInfo, appDefaultTitle) {
const titleText = computed(() => typeof titleInfo.value.pageName === "string" ? titleInfo.value.title : appDefaultTitle);
watch(
() => [titleInfo.value.title, titleText.value],
() => {
if (isBrowser() && titleText.value) {
document.title = titleText.value;
}
},
{
immediate: true
}
);
}
export {
useDocumentTitle
};