Şu kodumdaki hatayı çöz Şu kodlarımda checbox seçtiğimde ilgili checboxa ait batch…
- User
Şu kodumdaki hatayı çöz Şu kodlarımda checbox seçtiğimde ilgili checboxa ait batch kodunu pre penceresine eklemeli ama bunu yapmıyor tıklıyor checboxlara tepki yok sorun nerde ?
<!-- İkinci Kart --> <div class="card bg-gray-700 rounded-lg overflow-hidden group"> <div class="p-5"> <h3 onclick="toggleDropdown('dropdown2')" class="text-lg text-gray-100 font-semibold mb-2 cursor-pointer">Kart Başlığı 2</h3> <p class="text-gray-400">Kart içeriği burada yer alacak. Tamamen özelleştirilebilir.</p> <div id="dropdown2" class="dropdown-menu hidden relative w-full bg-gray-600 rounded-b-lg z-10 shadow-lg"> <div class="p-3"> <label class="flex items-center text-gray-200"> <input type="checkbox" class="form-checkbox h-5 w-5 text-blue-600" data-script="option3"> <span class="ml-2">Seçenek 3</span> </label> <label class="flex items-center text-gray-200 mt-2"> <input type="checkbox" class="form-checkbox h-5 w-5 text-blue-600" data-script="option4"> <span class="ml-2">Seçenek 4</span> </label> </div> </div> </div> </div> </div> <pre style="border-radius: 8px;" id="code" class="dos"></pre> </div> </div> <script src="main.js"></script> <script> function toggleDropdown(dropdownId) { var dropdown = document.getElementById(dropdownId); var isHidden = dropdown.classList.contains('hidden'); dropdown.classList.toggle('hidden', !isHidden); dropdown.classList.toggle('block', isHidden); } </script>// Checkbox'ların değişikliklerini izleyin document.querySelectorAll('input[type="checkbox"]').forEach(function(checkbox) { checkbox.addEventListener('change', function(e) { var codeElement = document.getElementById('code'); var combinedScripts = ''; // Kodları birleştirmek için kullanılacak boş bir string
// Tüm checkbox'ları kontrol edin document.querySelectorAll('input[type="checkbox"]').forEach(function(cb) { if (cb.checked) { // Checkbox seçildiyse, ilgili batch kodunu birleştir var script = scripts[cb.getAttribute('data-script')]; combinedScripts += '<code>' + hljs.highlight('dos', script).value + '</code>\n'; } }); codeElement.innerHTML = combinedScripts; // İçeriği güncelleyin });}); (dizin):62 cdn.tailwindcss.com should not be used in production. To use Tailwind CSS in production, install it as a PostCSS plugin or use the Tailwind CLI: https://tailwindcss.com/docs/installation (anonim) @ (dizin):62 main.js:11 Checkbox değişiklik olayı tetiklendi. main.js:18 Checkbox durumu: true highlight.min.js:108 Deprecated as of 10.7.0. highlight(lang, code, ...args) has been deprecated. highlight.min.js:108 Deprecated as of 10.7.0. Please use highlight(code, options) instead. highlight.min.js:107 Could not find the language 'dos', did you forget to load/include a language module? K @ highlight.min.js:107 f @ highlight.min.js:238 h @ highlight.min.js:186 (anonim) @ main.js:23 (anonim) @ main.js:17 highlight.min.js:238 Uncaught Error: Unknown language: "dos" at f (highlight.min.js:238:35) at Object.h [as highlight] (highlight.min.js:186:28) at main.js:23:52 at NodeList.forEach () at HTMLInputElement. (main.js:17:61) f @ highlight.min.js:238 h @ highlight.min.js:186 (anonim) @ main.js:23 (anonim) @ main.js:17 ___vscode_livepreview_injected_script:228 Uncaught TypeError: Cannot read properties of null (reading 'stack') at handleError (___vscode_livepreview_injected_script:228:35) at ___vscode_livepreview_injected_script:14:45 handleError @ ___vscode_livepreview_injected_script:228 (anonim) @ ___vscode_livepreview_injected_script:14
- Assistant
Hata mesajlarına göre 'dos' dilinin bilinmediğinden ve Highlight.js'in eski bir API kullanımından dolayı hata alınıyor. Bu durumu düzeltmek için iki adımda işlem yapabilirsiniz:
-
highlight('dos', script)kullanımını şeklinde güncelleyin. Ancak Highlight.js'de 'dos' dilini tanır bir modülün yüklenmediğini de unutmayın; herhangi bir dil modülü yüklenmediyse veya 'dos' modülü mevcut değilse, başka bir dil seçmeniz gerekebilir. Örneğin, 'batch' veya 'shell' gibi daha yaygın bir betik dilini kullanabilirsiniz.
-