GPT 和 React
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
這個範例展示了使用 Google 發布商廣告代碼 (GPT)、React 和 Next.js 的基本單頁應用程式 (SPA) 導入作業。
在 SPA 中使用 GPT 時,請注意以下幾點:
- 確保 GPT 僅載入一次。
- 使用
disableInitialLoad() 和 refresh() 來控制發出廣告請求的時機。詳情請參閱「控管廣告載入及重新整理」一文。
- 使用
setTargeting() 和 clearTargeting() 來控制套用至廣告版位的指定目標。詳情請參閱指定鍵/值。
- 請使用
destroySlots() 清除不再需要的廣告版位 (例如因元件卸載而移除廣告版位容器時)。
實作範例
[[["容易理解","easyToUnderstand","thumb-up"],["確實解決了我的問題","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["缺少我需要的資訊","missingTheInformationINeed","thumb-down"],["過於複雜/步驟過多","tooComplicatedTooManySteps","thumb-down"],["過時","outOfDate","thumb-down"],["翻譯問題","translationIssue","thumb-down"],["示例/程式碼問題","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],[],[],[]]