4***@qq.com
4***@qq.com
  • 发布:2020-08-14 17:54
  • 更新:2020-10-23 16:27
  • 阅读:1458

app端无法通过require或者import加载本地图片

分类:uni-app
// 底部tab active状态保持  
import HomeIcon from '@/assets/icon/首页.png';  
const HomeIconActive = require('@/assets/icon/首页-选中.png');  
const WorkbenchIcon = require('@/assets/icon/工作台.png');  
const WorkbenchIconActive = require('@/assets/icon/工作台-选中.png');  
const AlarmIcon = require('@/assets/icon/报警.png');  
const AlarmIconActive = require('@/assets/icon/报警-选中.png');  
const MineIcon = require('@/assets/icon/我的.png');  
const MineIconActive = require('@/assets/icon/我的-选中.png');  
console.log(HomeIcon)  
const TAB_LIST = [  
  { name: 'index', label: '首页', icon: HomeIcon, iconActive: HomeIconActive },  
  { name: 'workbench', label: '工作台', icon: WorkbenchIcon, iconActive: WorkbenchIconActive },  
  { name: 'alarm', label: '报警', icon: AlarmIcon, iconActive: AlarmIconActive },  
  { name: 'mine', label: '我的', icon: MineIcon, iconActive: MineIconActive },    
];
<view v-for="tab in tabs" :key="tab.name" class="action"   
        @click="NavChange(tab)">  
        <view class="cuIcon-cu-image">  
          <image :src="currentTab === tab ? tab.iconActive : tab.icon" ></image>  
          <image :src="HomeIcon" ></image>  
        </view>  
        <view :class="currentTab === tab ? 'text-green' : 'text-gray'">  
          {{ tab.label }}  
        </view>  
      </view>

在H5上没问题, 连接到模拟器上图标就不显示了!!!

2020-08-14 17:54 负责人:无 分享
已邀请:
p***@163.com

p***@163.com

把图片改成英文或者拼音试一试。项目中尽量不要出现中文命令的文件夹或文件

该问题目前已经被锁定, 无法添加新回复