djledda.de main
25개 이상의 토픽을 선택하실 수 없습니다. Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

useHead.ts 504 B

2 달 전
12345678910111213141516171819
  1. import { watchEffect, toValue, type MaybeRefOrGetter } from 'vue';
  2. import useDJSSRContext from "@/useDJSSRContext.ts";
  3. export default function useHead(params: {
  4. title: MaybeRefOrGetter<string>,
  5. }) {
  6. const context = useDJSSRContext();
  7. if (context) {
  8. context.head.title = params.title;
  9. } else {
  10. watchEffect(() => {
  11. const newTitle = toValue(params.title);
  12. if (newTitle) {
  13. document.title = newTitle;
  14. }
  15. });
  16. }
  17. }