HarmonyOS 鸿蒙Next虚拟机显示问题
HarmonyOS 鸿蒙Next虚拟机显示问题 运行后界面一片空白,但是在dev中previewer显示是正常的 这是代码
import MainViewModel from '../pages/GridData'
import ItemData from '../pages/GridItem'
@Entry
@Component
struct Setting{
build(){
Grid(){
ForEach(MainViewModel.getFirstGridData(),
(item:ItemData)=>{
GridItem(){
Column(){
Image(item.img)
.width(50)
.height(50)
Text(item.title)
//.width(15)//设置宽反而不好排列
.height(30)
}
.justifyContent(FlexAlign.Center)//对其方式
//.alignItems(HorizontalAlign.Center)
}
.backgroundColor('#FFFAFA')
.height(100)
.width(80)
.borderRadius(10)
},
item=>JSON.stringify(item)//生成数组项的键值
)
}
//.rowsTemplate('1fr 1fr 1fr')//行数
.columnsTemplate('1fr 1fr 1fr 1fr')//列数
.rowsGap(10)//行宽
.columnsGap(15)//列宽
.backgroundColor('#FFF5EE')
.height(220)
.borderRadius(20)
}
}
GridData
import ItemData from '../pages/GridItem'
export class MainViewModel{
//定义方法
getFirstGridData():Array<ItemData>{
//定义数组用来存放网格数据
let firstGridData:ItemData[]=[
new ItemData($r('app.string.grid_wind'),$r('app.media.wind')),
new ItemData($r('app.string.grid_water'),$r('app.media.water')),
new ItemData($r('app.string.grid_rock'),$r('app.media.rock')),
new ItemData($r('app.string.grid_ray'),$r('app.media.ray')),
new ItemData($r('app.string.grid_ice'),$r('app.media.ice')),
new ItemData($r('app.string.grid_grass'),$r('app.media.grass')),
new ItemData($r('app.string.grid_fire'),$r('app.media.fire')),
new ItemData($r('app.string.Expression_package_paimeng_surprise'),$r('app.media.paimeng_1')),
new ItemData($r('app.string.Expression_package_paimeng_pampered'),$r('app.media.paimeng_2')),
new ItemData($r('app.string.Expression_package_leishen_Drawing_blade'),$r('app.media.leishen_1'))
];
return firstGridData;
}
}
export default new MainViewModel();
GridItem
export default class ItemData{
title:Resource;
img?:Resource;
others?:Resource;
constructor(title:Resource,img?:Resource,others?:Resource) {
this.title=title;
this.img=img;
this.others;
}
}
这是显示是这样
更多关于HarmonyOS 鸿蒙Next虚拟机显示问题的实战教程也可以访问 https://www.itying.com/category-93-b0.html
我用你的代码虚拟机(模拟器)是能出来的。
目前来看就是你的模拟器本身有问题
这是我用的模拟器
更多关于HarmonyOS 鸿蒙Next虚拟机显示问题的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html
我后来有建了一个新项目,把代码放进一个文件里,在没加图的情况下可以。不过当时要下班了。可能是我的图或架构哪里出了问题,明天再试试。谢谢,
问题可能出现在了
import MainViewModel from '../pages/GridData'
import ItemData from '../pages/GridItem'
由于你没贴完整代码,我猜应该是用到了$r('')
出了问题,可以试着写到page里,而不是封装到组件里。
好,我试试,
基本信息
姓名:张三
职位:软件工程师
技能:Python, Java, C++
工作经验
2020-2022
公司名称:ABC有限公司
职位:初级软件工程师
描述:负责开发和维护公司内部工具。参与多个项目,使用Python和Java编写代码。
HarmonyOS鸿蒙Next虚拟机显示问题可能涉及多个方面。首先,检查虚拟机配置是否符合鸿蒙系统的要求,包括CPU、内存和显卡设置。其次,确保虚拟机软件版本支持鸿蒙Next,并已安装最新更新。如果显示异常,尝试调整虚拟机的显示设置,如分辨率、色彩深度等。此外,检查是否有兼容性问题,可能需要更新虚拟机软件或鸿蒙系统版本。如果问题依旧,考虑重新安装虚拟机软件或鸿蒙系统。确保所有操作符合鸿蒙Next的官方文档和指南。