jQuery在PUG中不起作用。即使我包含jQuery,也无法识别$符号

我已将我的jquery代码放在pug模板中,但未运行。我正在尝试运行jQuery函数,但是即使我也包含jQuery文件,我也遇到以下错误:-

@foreach ($order as $product)
    @if (!empty($product))
     <tr>      
       <td>{{$product->product->product_name}}</td> **//Here is the referencing**
       <td>{{$product->quantity}}</td>
       <td>{{$product->totalPrice}}</td>
       <td>{{$product->totalPrice * $product->quantity }}</td>
       <td>{{$product->created_at->diffForHumans()}}</td>
       <td>{{$product->orderStatus}}</td>                                                                         
     </tr>                                                   
   @endif                                                     
@endforeach 

这是我的哈巴狗模板:-

 40|                 P   

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

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


$ is not a function
huangshaoxu 回答:jQuery在PUG中不起作用。即使我包含jQuery,也无法识别$符号

错误是处理pug文件中的javascript / jquery行(使用-)。尝试以下方法:

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

请注意结尾处的点:script(type="text/javascript").。它将以下块作为纯文本写入script标记中。

Block in a Tag

本文链接:https://www.f2er.com/3129588.html

大家都在问