我想在我的 Angular 应用程序中放置 3 个 trustPilots。
import { Component, Input, OnInit } from '@angular/core';
declare global {
interface Window { Trustpilot: any; }
}
window.Trustpilot = window.Trustpilot || {};
@Component({
selector: 'app-trustbox-normal',
templateUrl: './trustbox-normal.component.html',
styleUrls: ['./trustbox-normal.component.scss']
})
export class TrustboxNormalComponent implements OnInit {
constructor() { }
ngOnInit(): void { }
ngAfterViewInit(){
const trustboxRef = document.getElementById('trustbox');
window.Trustpilot.loadFromElement(trustboxRef);
}
}
在 Brave 上,Firefox 运行良好,但在 Safari 中出现错误:
window.Trustpilot.loadFromElement 不是函数。(在 'window.Trustpilot.loadFromElement(trustboxRef)' 中,'window.Trustpilot.loadFromElement' 未定义)