浏览代码

修改路径

wangfumin 3 月之前
父节点
当前提交
a3f16f8998
共有 1 个文件被更改,包括 8 次插入6 次删除
  1. 8 6
      index.html

+ 8 - 6
index.html

@@ -18,12 +18,14 @@
       // 根据app参数设置favicon
       function setFavicon() {
         const appParam = getAppParam();
-        let faviconPath = '/favicon.ico'; // 默认图标
-        console.log(appParam, 6666)
-        if (appParam === '1') {
-          faviconPath = '/fire.ico';
-        } else if (appParam === '2') {
-          faviconPath = '/police.ico';
+        // 获取基础路径
+        const basePath = window.location.pathname.substring(0, window.location.pathname.lastIndexOf('/') + 1);
+        let faviconPath = basePath + 'favicon.ico'; // 默认图标
+        console.log(appParam, basePath, 6666)
+        if (appParam == '1') {
+          faviconPath = basePath + 'fire.ico';
+        } else if (appParam == '2') {
+          faviconPath = basePath + 'police.ico';
         }
         
         // 查找现有的favicon链接元素