Javascript 韩语编码问题 - 如何解决 github 页面图像 404 异步错误
Javascript Korean Encoding Issue - How do i resolve github pages image 404 async error
我正在尝试实现,当我按我的照片时,它会变成天使照片,而当我按名人照片时,它会变成幽灵照片。
在VSCode中,当你查看复制路径时它很好,但它是图像(异步)404错误,只是将它发布到GitHub页面上。帮我。因此,提交已经是 40.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>친구들을 위한 사이트</title>
<link rel="stylesheet" href="style.css" />
<link href="https://fonts.googleapis.com/css2?family=Gugi&display=swap" rel="stylesheet">
</head>
<body>
<h1>투표부탁해!!</h1>
<div class="container">
<div class="comment">누가 더 잘생겼나요?! 정답을 맞추면 선물이 와르르!</div>
<img src="images/제혁.png" class="image-jehyuk" onclick="changeImage()"></img>
<span>송제혁</span>
<img src="images/고수.png" class="image-gosu" onclick="changeImage2()"></img>
<span>고수</span>
</div>
<script src="index.js" defer></script>
</body>
</html>
const jehyuk = document.querySelector(".image-jehyuk");
const gosu = document.querySelector(".image-gosu");
const mainTitle = document.querySelector("h1");
const subTitle = document.querySelector(".comment");
function makeSound() {
let gosupick = new Audio("sounds/비명.mp3");
gosupick.play();
}
function thanksText() {
mainTitle.innerHTML = "감사합니다ㅎㅎ";
subTitle.innerHTML = "감사합니다ㅎㅎ";
}
function badText() {
mainTitle.innerHTML = "벌이닷!";
subTitle.innerHTML = "벌이닷!";
}
function changeImage() {
if (jehyuk.getAttribute("src") === "images/제혁.png") {
jehyuk.setAttribute("src", "images/제혁픽.png");
jehyuk.classList.add("bigger");
thanksText();
} else {
jehyuk.setAttribute("src", "images/제혁.png");
}
}
function changeImage2() {
if (gosu.getAttribute("src") === "images/고수.png") {
gosu.setAttribute("src", "images/고수픽.png");
gosu.classList.add("bigger");
badText();
} else {
gosu.setAttribute("src", "images/고수.png");
}
}
回答
Hello, 제혁! Way I see it's just korea language encoding error
如果您检查“Coriander”===“Coriander”,您可能会得到 false,因为它是写入差异编码类型(可能是 utf-8 和 utf-16)所以,您需要规范化您的文本
韩语答案
韩文单词看起来一样Javascript根据编码类型的性质,字符看起来一样,但被识别为不同的字符MacOS(经验) .
用控制台测试的结果,“Refining Pick” === “Refining Pick”在二进制数据中是false,所以说没有数据。通常,要解决此问题,可以在 String
类型上使用 normalize()
方法。
I ask for stack overflow user's patience. I'm so sorry using our own language but it is problem about korean language encoding type.
参考图片
我正在尝试实现,当我按我的照片时,它会变成天使照片,而当我按名人照片时,它会变成幽灵照片。
在VSCode中,当你查看复制路径时它很好,但它是图像(异步)404错误,只是将它发布到GitHub页面上。帮我。因此,提交已经是 40.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>친구들을 위한 사이트</title>
<link rel="stylesheet" href="style.css" />
<link href="https://fonts.googleapis.com/css2?family=Gugi&display=swap" rel="stylesheet">
</head>
<body>
<h1>투표부탁해!!</h1>
<div class="container">
<div class="comment">누가 더 잘생겼나요?! 정답을 맞추면 선물이 와르르!</div>
<img src="images/제혁.png" class="image-jehyuk" onclick="changeImage()"></img>
<span>송제혁</span>
<img src="images/고수.png" class="image-gosu" onclick="changeImage2()"></img>
<span>고수</span>
</div>
<script src="index.js" defer></script>
</body>
</html>
const jehyuk = document.querySelector(".image-jehyuk");
const gosu = document.querySelector(".image-gosu");
const mainTitle = document.querySelector("h1");
const subTitle = document.querySelector(".comment");
function makeSound() {
let gosupick = new Audio("sounds/비명.mp3");
gosupick.play();
}
function thanksText() {
mainTitle.innerHTML = "감사합니다ㅎㅎ";
subTitle.innerHTML = "감사합니다ㅎㅎ";
}
function badText() {
mainTitle.innerHTML = "벌이닷!";
subTitle.innerHTML = "벌이닷!";
}
function changeImage() {
if (jehyuk.getAttribute("src") === "images/제혁.png") {
jehyuk.setAttribute("src", "images/제혁픽.png");
jehyuk.classList.add("bigger");
thanksText();
} else {
jehyuk.setAttribute("src", "images/제혁.png");
}
}
function changeImage2() {
if (gosu.getAttribute("src") === "images/고수.png") {
gosu.setAttribute("src", "images/고수픽.png");
gosu.classList.add("bigger");
badText();
} else {
gosu.setAttribute("src", "images/고수.png");
}
}
回答
Hello, 제혁! Way I see it's just korea language encoding error
如果您检查“Coriander”===“Coriander”,您可能会得到 false,因为它是写入差异编码类型(可能是 utf-8 和 utf-16)所以,您需要规范化您的文本
韩语答案
韩文单词看起来一样Javascript根据编码类型的性质,字符看起来一样,但被识别为不同的字符MacOS(经验) .
用控制台测试的结果,“Refining Pick” === “Refining Pick”在二进制数据中是false,所以说没有数据。通常,要解决此问题,可以在 String
类型上使用 normalize()
方法。
I ask for stack overflow user's patience. I'm so sorry using our own language but it is problem about korean language encoding type.