在將導(dǎo)航菜單作為單獨(dú)的 html 文件加載時(shí),我試圖使用 jquery 來初始化它的活動(dòng)類。我不熟悉 PHP,而且我對(duì)網(wǎng)站生成還很陌生,所以我對(duì) JS 和常用語言(HTML、CSS 和 JS)之間的集成不太熟悉。問題是由 JSZip 創(chuàng)建的 .zip 存檔條目將具有與之關(guān)聯(lián)的文件修改時(shí)間戳。這會(huì)導(dǎo)致不同時(shí)間生成的文件之間存在微小差異(通常為幾個(gè)字節(jié))。因此,我們需要手動(dòng)指定文件時(shí)間戳,并確保我們僅在 .zip 存檔中創(chuàng)建虛擬文件夾。這種方法應(yīng)該對(duì)你有用(每次都給出相同的 MD5 哈希值):import JSZip = require('jszip');import crypto = require('crypto');// You must fix the date (set to the same value) so that the zip archive timestamps will be equal.// Also we must create virtual folders or they will be assigned timestamps too, resulting in a different hash.const options = { date: new Date('2019-07-24 06:00:00Z'), createFolders: false};zip.file("hello.txt", "Hello World\n", options);zip.file("nested/hello.txt", "Hello World\n", options);zip.generateAsync({ type: 'nodebuffer', mimeType: 'application/epub+zip', compression: 'DEFLATE', compressionOptions: { level: 9 },}) .then(buf => { const md5 = crypto.createHash('md5'); let result = md5.update(buf).digest('hex'); console.dir(result); });我希望導(dǎo)航菜單中的當(dāng)前項(xiàng)目以藍(lán)色突出顯示。當(dāng)點(diǎn)擊但未選擇(即頁面實(shí)際上并未加載)時(shí),這將成功設(shè)置為活動(dòng)類(背景為藍(lán)色)。
通過 Jquery 加載導(dǎo)航欄時(shí)設(shè)置活動(dòng)類
幕布斯7119047
2021-08-20 10:29:11