[英]Trustpilot: window.Trustpilot.loadFromElement is undefined (Safari)
我想在我的 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' 未定義)
可能與Next.js 中的這個Trustpilot TrustBoxes 有關
您是否嘗試在 loadFromElement 的調用中添加延遲,以便為 Truspilot js 腳本提供足夠的時間來加載?
我刪除
window.Trustpilot = window.Trustpilot || {};<\/code>
window.Trustpilot = window.Trustpilot || {};<\/code> 從代碼中,現在它在 Safari 上也可以正常工作。
"
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.