代码
function LevelGetImages(level: number) {let res = []const marks = [{ mod: 20, image: Images.setting.level_king },{ mod: 15, image: Images.setting.level_queen },{ mod: 10, image: Images.setting.level_moon },{ mod: 5, image: Images.setting.level_star },]for (let i = 0; i < marks.length; i++) {const value = ~~(level / marks[i].mod)const rest = level % marks[i].modfor (let j = 0; j < value; j++) {res.push(marks[i].image)}level = rest}return (<View style={{ flexDirection: "row", alignItems: "center" }}>{res.map((item) => (<Image key={item.index} source={item} style={{ width: fitSize(16), height: fitSize(16) }} />))}</View>)
}
使用
{LevelGetImages(user?.level)}