使用来自资产目录

时间:2017-10-27 19:42:06

标签: php laravel

我有一个js文件:resources / assets / js / main.js

在我的刀片中,我尝试以下列方式访问它:

<script src="{{ asset('js/main.js') }}"></script>
// or
<script src="{{ asset('assets/js/main.js') }}"></script>
<script src="{!! asset('js/main.js') !!}"></script>
<script src="{!! asset('assets/js/main.js') !!}"></script>

它将网址解析为mydomain.dev/js/main.js,给我一个404。 我怎样才能让它发挥作用?

2 个答案:

答案 0 :(得分:1)

请参阅此链接,您无需将外部文件存储到资源目录,仅使用公共目录,

SELECT tblStudent.student_id,
       [monthly_fee]+[book_fee] AS [Total Fee],
       Sum(tblReceipt.receipt_amount) AS SumOfreceipt_amount,
       [monthly_fee]+[book_fee]-Nz(Sum([tblReceipt]![receipt_amount]),0) AS Outstanding,
       tblReceipt.month,
       tblReceipt.year
FROM tblStudent
LEFT JOIN tblReceipt ON tblStudent.student_id = tblReceipt.student_id
GROUP BY tblStudent.student_id,
         [monthly_fee]+[book_fee],
         tblReceipt.Description,
         tblReceipt.month,
         tblReceipt.year
HAVING (((Sum(tblReceipt.receipt_amount))>0)
        AND ((tblReceipt.Description)='Total Fee')
        AND (([monthly_fee]+[book_fee]-Nz(Sum([tblReceipt]![receipt_amount]),0))>0)
        AND ((tblReceipt.month)=[Forms]![frmDialogMonth3]![cb_Month])
        AND ((tblReceipt.year)=[Forms]![frmDialogMonth3]![txt_Year]))
OR (((Sum(tblReceipt.receipt_amount)) IS NULL))
ORDER BY tblStudent.student_id;

都获得你的项目网址。 请看到这个我希望你能理解我在说什么 laravel assets directory

答案 1 :(得分:-1)

步骤1)您需要像这样

在刀片中注册您的js文件
<script src="{{ asset('js/main.js') }}"></script> 

步骤2)确保你的js文件位于公共目录中,因为它将从public / js中获取js文件

步骤3)使用此命令清除缓存: -

php artisan config:cache