useTitle

package version >0.1.1

shadcn any version

install

npm
1npm i @cmtlyt/lingshu-toolkit
shadcn
1npx shadcn@latest add https://cmtlyt.github.io/lingshu-toolkit/r/vueUseTitle.json

usage

1import { useTitle } from '@cmtlyt/lingshu-toolkit/vue'
2// or
3import { useTitle } from '@cmtlyt/lingshu-toolkit/vue/use-title'
4
5// 基本使用
6useTitle('我的页面标题');
7
8// 获取返回值,手动控制
9const title = useTitle('初始标题');
10title.value = '新标题'; // 手动修改
11
12// 使用响应式数据
13const pageName = ref('Home');
14const title = useTitle(pageName);
15
16// 在模板中使用
17<template>
18  <input v-model="title" placeholder="修改标题" />
19</template>
20
21// 配置选项
22useTitle('页面标题', { restoreOnUnmount: false });