wuhb 2 meses atrás
pai
commit
eccbe158b7
1 arquivos alterados com 24 adições e 10 exclusões
  1. 24 10
      components/uni-navbar-lite/uni-navbar-lite.uvue

+ 24 - 10
components/uni-navbar-lite/uni-navbar-lite.uvue

@@ -23,7 +23,7 @@
 </template>
 
 <script>
-    import iconpath from './uniicons.ttf'
+    // import iconpath from './uniicons.ttf'
     export default {
         name: "uni-navbar",
         props: {
@@ -54,15 +54,23 @@
             }
         },
         created() {
-            uni.loadFontFace({
-                global: false,
-                family: 'UniIconsFontFamily',
-                source: iconpath,
-                success() { },
-                fail(err) {
-                    console.log(err);
-                },
-            })
+			// #ifndef WEB
+				// 非WEB平台使用原有方式
+				const iconpath = './uniicons.ttf';
+				uni.loadFontFace({
+					global: false,
+					family: 'UniIconsFontFamily',
+					source: iconpath,
+					success() { },
+					fail(err) {
+						console.log(err);
+					},
+				});
+			// #endif
+            // #ifdef WEB
+				// WEB平台使用CSS加载字体
+			// #endif
+						
             const sys = uni.getSystemInfoSync()
             const statusBarHeight = sys.statusBarHeight
             this.statusBarHeight = statusBarHeight
@@ -93,6 +101,12 @@
 </script>
 
 <style>
+	// #ifdef WEB
+	@font-face {
+		font-family: 'UniIconsFontFamily';
+		src: url('/components/uni-navbar-lite/uniicons.ttf') format('truetype');
+	}
+	// #endif
     .uni-icons {
         font-family: "UniIconsFontFamily" !important;
         font-size: 22px;