Laravel 5.6 - Do I need to include JQuery or is it already included in the app.js?

后端 未结 1 533
情书的邮戳
情书的邮戳 2021-02-19 05:20

I have created a Laravel 5.6 project on my local.

I have in

1条回答
  •  余生分开走
    2021-02-19 05:58

    jQuery is loaded via your app.js, which is only loaded once the page is ready because of the defer attribute in your script tag.

    Your inline script tag where you call jQuery(document).ready is loaded as the page renders, therefore executed before the app.js has been loaded. Hence the error, since jQuery is not yet loaded at that time.

    To fix it, simply remove the defer attribute from the script tag.

    The defer attribute is a boolean attribute.

    When present, it specifies that the script is executed when the page has finished parsing.

    For more information about the defer attribute: https://www.w3schools.com/tags/att_script_defer.asp

    0 讨论(0)
提交回复
热议问题