亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

如何在blade.php 中使用來自外部.js 文件的代碼?

如何在blade.php 中使用來自外部.js 文件的代碼?

PHP
森林海 2021-10-22 10:57:42
我有資源/js/jquery.js 文件,我在其中聽按鈕被按下拋出 jQuery,并執行一些操作。問題是我無法將 jquery.js 導入到我的 .blade.php 中。我通過 public/js 添加了 jquery.min.js。我在.blade.php 中有什么<form id="RegisterForm" method="GET">    <input type="text" name="username" id="username">    <input type="text" name="email" id="email">    <input type="text" name="password" id="password">    <input type="text" name="password2" id="password2">    <input type="submit" value="REGISTER" id="registerButton"></form><script src="{{asset('js/jquery.min.js')}}"></script><script src="/js/jquery.js"></script>我在jquery.js 中有什么window.onload = function(){$(document).ready(function(){    $('#registerButton').click(function(){        alert("Hello");    }); });}我需要得到 alert("Hello");問題是,當單擊按鈕時沒有任何反應,我不確定是因為我錯誤地添加了 jquery.min.js,還是僅包含我的 jquery.js 腳本是錯誤的。或者這是不可能的,我必須在我的 .blade.php 的正文底部添加它<script type="text/javascript">    window.onload = function(){        $(document).ready(function(){            $('#registerButton').click(function(){                alert("Hello");            });        });    }</script>
查看完整描述

1 回答

?
慕慕森

TA貢獻1856條經驗 獲得超17個贊

我們假設您在 public/assets 中有您的 js 文件夾,

然后

添加類似這樣的外部 js。


<script src="{{ asset('js/jquery.min.js') }}"></script>

<script src="{{ asset('js/jquery.js') }}></script>

并在 2 個花括號之后/之前添加空格。


我希望你的問題會得到解決


查看完整回答
反對 回復 2021-10-22
  • 1 回答
  • 0 關注
  • 195 瀏覽

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號