簡體   English   中英

Jquery 在 PUG 內無法工作。 即使我包含了 jQuery 也無法識別 $ 符號

[英]Jquery not working inside PUG. Isn't recognising $ sign even though I have included jQuery

我已將我的 jquery 代碼放在 pug 模板中,但它沒有運行。 我正在嘗試運行 jQuery function 但即使我也包含了 jQuery 文件,我也會收到以下錯誤:-

 40|                 P   

    41|                     script(type="text/javascript")

  > 42|                        -  $("#image-drop-area").dropzone({ url: "/file/post" })


$ is not a function

這是我的哈巴狗模板:-

        p
            label(for="tags") Tags (Seperated by comma): 
            input(type="text" name="tags" id="tags" required autofocus)

        P   
            script(type="text/javascript")
               -  $("#image-drop-area").dropzone({ url: "/file/post" })

錯誤是處理 pug 文件中的 javascript/jquery 行(帶有- )。 試試這個:

script(type="text/javascript").
  $("#image-drop-area").dropzone({ url: "/file/post" })

注意末尾的點: script(type="text/javascript"). . 它將以下塊作為純文本寫入script標記。

在標簽中阻止

暫無
暫無

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

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