我有以下代码用于在我的登录项目中使用 jquery backstretch 插件。我的项目是 asp.net 核心,登录页面是一个视图页面。但该代码与图像的本地地址有问题。当我将图像的地址更改为正常工作的 http 地址时,我的图像已保存在 wwwroot/assets/admin/pages/media/bg 中。错误的代码:
<script>
$.backstretch([
"~/assets/admin/pages/media/bg/1.jpg",
"~/assets/admin/pages/media/bg/2.jpg",
"~/assets/admin/pages/media/bg/3.jpg",
"~/assets/admin/pages/media/bg/4.jpg"
], {
fade: 1000,
duration: 8000
}
);
</script>
这是正常工作:
<script>
$.backstretch([
"https://www.w3schools.com/images/w3schools_green.jpg",
"https://www.w3schools.com/images/w3schools_green.jpg",
"https://www.w3schools.com/images/w3schools_green.jpg",
"https://www.w3schools.com/images/w3schools_green.jpg"
], {
fade: 1000,
duration: 8000
}
);
</script>