updatge
This commit is contained in:
19
app/useHead.ts
Normal file
19
app/useHead.ts
Normal file
@@ -0,0 +1,19 @@
|
||||
import { watchEffect, toValue, type MaybeRefOrGetter } from 'vue';
|
||||
import useDJSSRContext from "@/useDJSSRContext.ts";
|
||||
|
||||
export default function useHead(params: {
|
||||
title: MaybeRefOrGetter<string>,
|
||||
}) {
|
||||
const context = useDJSSRContext();
|
||||
|
||||
if (context) {
|
||||
context.head.title = params.title;
|
||||
} else {
|
||||
watchEffect(() => {
|
||||
const newTitle = toValue(params.title);
|
||||
if (newTitle) {
|
||||
document.title = newTitle;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user