# useTitle

#### 基础用法

```html

<template>
   <div>Hello World! {{title}}</div>
</template>

<script setup lang="ts">

import { useTitle } from "hooks-vue3";

// 使用默认标题模板，直接将 "Vue App" 设置为页面标题
const title = useTitle("Vue App");

// 使用自定义标题模板，将 "Page Title" 添加到页面标题中
useTitle("Page Title", { template: "My Site | %s", isPrevOnUnmount: true });
</script>

```

### API

```typescript
const title = useTitle();
```

### 参数

```typescript

export type UseTitleOptions = {
  template?: string | ((title: string) => string); //将默认的标题模板 %s 应用于指定的标题字符串
  isPrevOnUnmount?: boolean; //是否在组件卸载重置上一个的标题
};

function useTitle(newTitle?: string, options?: UseTitleOptions): Ref<string>

```

```typescript
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://laterly.gitbook.io/hooks-vue3/usetitle.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
