# Function: getLeaderboard

getLeaderboard(type: number): Promise‹ReadonlyWithExtensions‹Leaderboard››

根据给定的排行榜类型,获取排行榜列表。

example

import { rankSystem } from "@timi/mogs-sdk";
//需要的排行榜类型
const rankType = 1;
// 获取该类型排行榜的实例
this.leaderboard = await rankSystem.getLeaderboard(rankType);
1
2
3
4
5

throws {@link MogsError}

# 参数:

属性 类型 描述
type number 排行榜类型,该类型需要游戏策划预先在游戏的排行榜配置 (opens new window)中进行配置。

# 返回值:

Promise‹ReadonlyWithExtensions‹Leaderboard››

Leaderboard结构

属性 类型 描述
playerRankInfos PlayerRankInfo[] (排行榜内)玩家列表
total number 排行榜总人数
type number 排行榜类型
getSelfRankInfo Method 获取当前用户在该排行榜内的信息
loadMore Method 加载更多排行榜数据
offLoadMore Method 取消注册 当前排行榜加载更多 事件处理函数
offRefresh Method 取消注册 当前排行榜刷新 事件处理函数
onLoadMore Method 注册 当前排行榜加载更多 事件处理函数
onRefresh Method 注册 当前排行榜刷新 事件处理函数
refresh Method (全量)刷新排行榜
uploadRankValue Method 上报排行榜数值

返回一个只读的 leaderboard 排行榜对象,该对象拥有的属性和方法请查看 Leaderboard