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后綴
,因?yàn)橹虚g的那個(gè)hash是隨時(shí)會變化的,所以在頁面引入js文件的時(shí)候,就不能寫死文件的路徑,而是使用mix('app.js')
,此時(shí)laravel會自動去匹配當(dāng)前的app.js
對應(yīng)哪個(gè)app+hash+.js
的文件(項(xiàng)目public目錄下會有一個(gè)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.