Tags 使用angular 6.1在页面视图源上不显示元标记
我使用的是角度,我想动态添加元标记 我正在使用表单: 我尝试了下面的代码,它显示在inspect元素(控制台)中,但没有显示在源代码中:Tags 使用angular 6.1在页面视图源上不显示元标记,tags,angular6,show,meta,Tags,Angular6,Show,Meta,我使用的是角度,我想动态添加元标记 我正在使用表单: 我尝试了下面的代码,它显示在inspect元素(控制台)中,但没有显示在源代码中: import { NgModule } from '@angular/core'; import { MetaGuard } from '@ngx-meta/core'; import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/cor
import { NgModule } from '@angular/core';
import { MetaGuard } from '@ngx-meta/core';
import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ChildrouterComponent } from './about/childrouter/childrouter.component';
const routes: Routes = [
{
path: '',
canActivateChild: [MetaGuard],
children: [
{
path: 'home',
component: HomeComponent,
data: {
meta: {
title: 'home home',
keywords: 'home,home,home,home,home',
description: 'Home, home sweet home... and what?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'about',
component: AboutComponent,
data: {
meta: {
title: 'about hello',
keywords: 'about,about,about,about,about,about,about',
description: 'Have you seen my rubber hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'dashboard',
component: DashboardComponent,
data: {
meta: {
title: 'dashboard hello',
keywords: 'dashboard,dashboard,dashboard,dashboard,dashboard,dashboard,dashboard',
description: 'Have you seen my dashboard hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
}
]
}
]
@NgModule({
imports: [RouterModule.forRoot(routes),
MetaModule.forRoot()
],
exports: [RouterModule]
})
export class AppRoutingModule { }
它在检查元素中运行良好,但在页面查看源代码中未显示任何元标记尝试在生产环境中构建应用程序并运行它,可能会在那里查看
import { NgModule } from '@angular/core';
import { MetaGuard } from '@ngx-meta/core';
import { MetaModule, MetaLoader, MetaStaticLoader, PageTitlePositioning } from '@ngx-meta/core';
import { Routes, RouterModule } from '@angular/router';
import { HomeComponent } from './home/home.component';
import { AboutComponent } from './about/about.component';
import { DashboardComponent } from './dashboard/dashboard.component';
import { ChildrouterComponent } from './about/childrouter/childrouter.component';
const routes: Routes = [
{
path: '',
canActivateChild: [MetaGuard],
children: [
{
path: 'home',
component: HomeComponent,
data: {
meta: {
title: 'home home',
keywords: 'home,home,home,home,home',
description: 'Home, home sweet home... and what?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'about',
component: AboutComponent,
data: {
meta: {
title: 'about hello',
keywords: 'about,about,about,about,about,about,about',
description: 'Have you seen my rubber hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
},
{
path: 'dashboard',
component: DashboardComponent,
data: {
meta: {
title: 'dashboard hello',
keywords: 'dashboard,dashboard,dashboard,dashboard,dashboard,dashboard,dashboard',
description: 'Have you seen my dashboard hello?',
'og:image': 'https://upload.wikimedia.org/wikipedia/commons/f/f8/superraton.jpg',
'og:type': 'website',
'og:locale': 'en_US',
'og:locale:alternate': 'en_US,nl_NL,tr_TR'
}
}
}
]
}
]
@NgModule({
imports: [RouterModule.forRoot(routes),
MetaModule.forRoot()
],
exports: [RouterModule]
})
export class AppRoutingModule { }