繁体   English   中英

如何在惯性js和vue3中设置和更改(页面标题)

[英]How to set and change ( title of page ) in inertiajs and vue3

我在Laravel8中使用vue3和惯性Js

如果我更改页面,我想更改(页面的标题

我在 Inertia 文档中检查了这段代码,但它不适用于我,并且页面标题没有改变我安装了 vue-meta

  metaInfo() {
     return() {
         title: “Home Page”,
     }
  }

return()是一个属性,而不是 function。 :) 所以你应该这样做: return

// parent
metaInfo: {
  meta: [{
    vmid: 'description',
    name: 'description',
    content: 'my standard description',
  }]
}

// child
metaInfo() {
  return {
    meta: [{
      vmid: 'description',
      name: 'description',
      content: this.description,
    }]
  }
},

这个 Vue 文档中了解更多信息

根据 Inertia v0.4.0,他们现在捆绑了自己的inertia-head组件,您可以使用它来添加元标记和更新标题。 不再需要vue-meta

只需将以下内容直接添加到您的页面组件中:

<inertia-head>
  <title>Your page title</title>
  <meta name="description" content="Your page description">
</inertia-head>

您可以在v0.4.0 的更改日志中找到更多信息。

在“inertia-vue3”中,我们如何知道“描述”发生了变化?

import { Head } from '@inertiajs/inertia-vue3'

<Head>
  <title>About - My app</title>
  <meta head-key="description" name="description" content="This is a page specific description" />
</Head>

视图源中,什么都无法理解!

<!DOCTYPE html>
<html lang="en">
    <head>
        <meta charset="utf-8">
        <meta name="viewport" content="width=device-width, initial-scale=1">


        
        
        <title inertia>test</title>
        

    <body>   
    </body>
</html>

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM