Laravel资产与混合

时间:2018-06-19 11:06:26

标签: laravel include assets

当您必须包含一些assetmix文件时,我无法理解使用jscss Laravel帮助程序之间的区别。

<script src="{{ mix('/js/app.js') }}"></script>

VS

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

两者都会生成public文件夹的链接,所以它们之间有什么区别吗?使用其中一个而不是另一个更好吗?在哪种情况下更好?

1 个答案:

答案 0 :(得分:7)

asset is just a helper to get the correct path to the file you are using as parameter, where mix also includes a version number, to help prevent caching of assets.

Read this page to understand more about mix.