当 Javascript 代码在 HTML 文件中时,这不是问题。但是,当我将脚本标记的内容移动到 js 文件以用于其他 HTML 文件时,就会出现无法读取图像的问题。代码如下。
脚本.js
function mouseOverSelf() {
let img = document.getElementById("changeImg1");
let m = document.getElementById("changeColor1");
img.src = "{{ url_for('static', filename='img/edit_w.svg') }}";
m.style.color = "white";
}
function mouseOutSelf() {
let img = document.getElementById("changeImg1");
let m = document.getElementById("changeColor1");
img.src = "{{ url_for('static', filename='img/edit.svg') }}";
m.style.color = "black";
}
function mouseOverExcel() {
let img = document.getElementById("changeImg2");
let m = document.getElementById("changeColor2");
img.src = "{{ url_for('static', filename='img/spreadsheet_w.svg') }}";
m.style.color = "white";
}
function mouseOutExcel() {
let img = document.getElementById("changeImg2");
let m = document.getElementById("changeColor2");
img.src = "{{ url_for('static', filename='img/spreadsheet.svg') }}";
m.style.color = "black";
}
索引.html
<script type="text/javascript" src="{{ url_for('static', filename='js/script.js') }}"></script>
我能怎么做?
慕田峪4524236
相关分类