PeopleEngineer
PeopleEngineer
  • 发布:2025-11-18 13:15
  • 更新:2025-11-18 13:15
  • 阅读:18

nvue 多字体问题

分类:nvue

问题描述

环境: Nvue 中使用 uni-app 的 dom 模块配置自定义字体

配置需求: 需要配置三种字体:

  • textfont = 文本字体
  • iconfont1 = 图标1
  • iconfont2 = 图标2

当前代码:

const domModule = uni.requireNativePlugin('dom')  
domModule.addRule('fontFace', {  
    'fontFamily': "textfont",  
    'src': 'url(base64xxxx)'  
});  

domModule.addRule('fontFace', {  
    'fontFamily': "iconfont1",   
    'src': 'url(base64xxxx)'  
});  

domModule.addRule('fontFace', {  
    'fontFamily': "iconfont2",  
    'src': 'url(base64xxxx)'  
});

问题现象:

  • 只有第一个配置的字体(textfont)生效
  • 其他两个字体(iconfont1、iconfont2)不生效
  • 如果将 iconfont1 排序到第一位,则 iconfont1 生效,其他不生效
  • 在 Vue 页面中三种字体都正常,排除字体文件本身的问题

核心问题: 在 Nvue 中,domModule.addRule 方法只有第一条字体配置生效,后续的字体配置不生效。

2025-11-18 13:15 负责人:无 分享
已邀请:

要回复问题请先登录注册