簡體   English   中英

Barba JS 向 DOM 添加腳本

[英]Barba JS adding scripts to the DOM

barba.init({ transitions: [ {
      name: 'general-transition-opacityfade',
      once({next}){
        animationEnter(next.container)
      },
      leave: ({current}) => animationLeave(current.container),
      enter({next}){
        animationEnter(next.container); }},

使用 Barba.JS 重新運行我的 JS 腳本有沒有辦法將腳本添加到 DOM 並在頁面輸入時運行?

您可以在引導您進入新頁面的轉換之后指定 barba 在進入之前可以執行的操作。

例如,如果您想執行一個腳本或只是一段代碼到下一個轉換,您可以使用它。

 barba.init({ views: [{ namespace: 'index', beforeLeave(data) { // do something before leaving the current `index` namespace } }, { namespace: 'contact', beforeEnter(data) { // do something before entering the `contact` namespace } }] });

您可以在您創建並希望與 barbajs 鏈接的每個 HTML 文檔中找到“命名空間”標簽,希望這對您有用。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM