Laravel资产vs混合 [英] Laravel asset vs mix
本文介绍了Laravel资产vs混合的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当您必须包含某些js
或css
文件时,我不了解使用asset
或mix
Laravel帮助器之间的区别.
I don't get to understand the difference between using asset
or mix
Laravel helper when you have to include some js
or css
file.
<script src="{{ mix('/js/app.js') }}"></script>
与
<script src="{{ asset('/js/app.js') }}"></script>
两者都会生成指向public
文件夹的链接,所以它们之间有什么区别吗?使用其中一个而不是另一个更好吗?在哪种情况下更好?
Both generates a link to public
folder so is there any difference between them? Is it better to use one of them instead of the other? In which context is it better?
推荐答案
asset
只是一个帮助程序,用于获取到您用作参数的文件的正确路径,其中mix
还包括版本号,以提供帮助防止缓存资产.
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.
这篇关于Laravel资产vs混合的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文