php - Laravel 里的mix方法和asset方法有啥区别?
巴扎黑
巴扎黑 2017-05-16 13:09:08
0
1
393

刚接触laravel,在引用资源时,看到有asset方法和mix方法,返回的都是同一个目录,想问下这两有啥区别?

巴扎黑
巴扎黑

reply all(1)
漂亮男人

Laravel comes with laravel-mix, which is used to package static resources such as js, css, images, etc. The name of the generated file will be: app.asjduiik2l1323879dasfydua23.js, 即js原文件名+hash+.js后缀,因为中间的那个hash是随时会变化的,所以在页面引入js文件的时候,就不能写死文件的路径,而是使用mix('app.js'),此时laravel会自动去匹配当前的app.js对应哪个app+hash+.js的文件(项目public目录下会有一个mix-manifest.json, which stores the corresponding relationship between the two, and the file will be updated every time the static resources are packaged).

Sometimes we don’t want the hash value to be added to the name of the static resource (in most cases, it is a third-party library that is not a nodejs module and is introduced independently). At this time, we can directly use the asset method, which is simple and crude. Look for the file you named it.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!