gpt4 book ai didi

angular - 是否可以在没有 SSR 的情况下使用 Googlebot 识别的 Angular 8 组件设置 HTML 标题和元标记?

转载 作者:行者123 更新时间:2023-12-04 16:33:33 26 4
gpt4 key购买 nike

我的组件使用 setTitleupdateTag更新标题和标签。屏幕上的剩余数据通过模板绑定(bind)到通过主机请求获得的对象进行更新。 Google 搜索控制台显示正确的屏幕数据,但显示默认标题和元标记。
有没有办法在没有 Universal 的情况下解决这个问题?

constructor(private dataService: DataService, private route: ActivatedRoute, private meta: Meta,
private title: Title, private canonicalService: CanonicalService) {}

ngOnInit() {
this.canonicalService.setCanonicalURL();
this.route.params.subscribe(
params => {
const id = +params['id'];
this.getLicense(id);
}
);
let list = sessionStorage.getItem('liclist');
if (list) {
this.licList = JSON.parse(list);
}
this.dataService.getEnum().subscribe((data: Enum[]) => {
this.enums = data;
});
}

getLicense(id) {
this.dataService.getLicense(id).subscribe((data: License) => {
this.license = data;
this.licListPtr = this.licList.findIndex(x => x === id);
this.meta.updateTag({
name: "keywords",
content: !!this.license.keywords ? this.license.keywords.toLowerCase().replace("~", ", ") : ' '
});
let desc = this.license.licDesc;
if (!!this.license.occs) {
this.license.occs.forEach(o => {
desc += `\nOccupation ${o.occCode} ${o.occTitle.toLowerCase()}`;
});
this.meta.updateTag({
name: "description",
content: desc
});
this.title.setTitle(`Licensing for ${this.license.licTitle}`);
}

})
}

最佳答案

我认为目前没有像 Angular Universal 这样的 SSR 是不可能的.
我在一些项目中遇到了同样的问题。您的元标记确实正在更新,但网络爬虫可能只查看它们一次。我也注意到某些社交网络的爬虫也有同样的限制。我认为随着 SPA 变得越来越流行,我们可能会看到爬虫开始适应。

关于angular - 是否可以在没有 SSR 的情况下使用 Googlebot 识别的 Angular 8 组件设置 HTML 标题和元标记?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/64177439/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com