【问题标题】:How to set and change ( title of page ) in inertiajs and vue3如何在惯性js和vue3中设置和更改(页面标题)
【发布时间】:2021-08-17 07:52:46
【问题描述】:

我将 vue3inertiaJsLaravel8

一起使用

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

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

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

【问题讨论】:

    标签: laravel vue.js vuejs3 inertiajs


    【解决方案1】:

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

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

    通过this Vue doc了解更多信息

    【讨论】:

      【解决方案2】:

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

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

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

      您可以在change logs of v0.4.0找到更多信息。

      【讨论】:

        猜你喜欢
        • 2023-03-05
        • 1970-01-01
        • 2019-06-12
        • 1970-01-01
        • 2021-11-06
        • 2017-10-19
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多