我怎样才能使标题栏在广告上动态化?

我看到广告项目有标题栏。但标题在public/index.html中。资源文件夹外部

所以我很难使它动态化。每页必须有不同的标题。如果是一样的,对SEO的影响很大

my public/index.html如下:

<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <link rel="icon" href="<%= BASE_URL %>favicon.ico">
    <title>test-vuetify</title>
    <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Roboto:100,300,400,500,700,900">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/@mdi/font@latest/css/materialdesignicons.min.css">
  </head>
  <body>
    <noscript>
      <strong>We're sorry but test-vuetify doesn't work properly without JavaScript enabled. Please enable it to continue.</strong>
    </noscript>
    <div id="app"></div>
    <!-- built files will be auto injected -->
  </body>
</html>

如何解决此问题?我想让每一页的标题都不一样。根据页面内容


解决方案

很难从问题中准确地区分您的约束条件,但以防这有助于其他人将其Vutify标题栏设置为动态.

index.js中,将一些元(&Q;)添加到路由:

import VueRouter from 'vue-router';

Vue.use(VueRouter);

const routes = [
  {
    path: '/page1',
    name: 'page-1',
    component: ...,
    meta: {
      title: 'Page 1'
    }
  },
  {
    path: '/page2',
    name: 'page-2',
    component: ...,
    meta: {
      title: 'Page 2'
    }
  }
]

const router = new VueRouter({
  mode: 'history',
  base: (your base url),
  routes: routes,
});

export default router

然后在Vutify标题栏中,使用上面定义的路由元:

<v-toolbar-title>{{ $route.meta.title || "Default title" }}</v-toolbar-title>

相关文章

怎么写html

2023-06-08 html