导航栏定制
定制导航栏标题、按钮、菜单项等能力
API 调用
QN.navigator.setTitle(options)
自定义标题
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.query |
Object |
|
|
接口调用参数 |
options.query.title |
String |
|
|
标题文案 |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
// 文字标题
QN.navigator.setTitle({
query: {
title: '我是标题'
}
}).then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.setTitle({
query: {
title: '我是标题'
},
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.addButton(options)
添加导航栏自定义按钮
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.query |
Object |
|
|
接口调用参数 |
options.query.iconName |
String |
iconName和iconImg二选一 |
|
千牛客户端内置 icon 名称,内置 icon 列表参看本页附录 |
options.query.iconImg |
String |
iconName和iconImg二选一 |
|
图标图片,URL 或 Base64 (暂不支持 URL) |
options.query.text |
String |
可选 |
|
图标文本,如果 iconName 和 iconImg 都没有值,则展示文本 |
options.query.tapEvent |
String |
|
|
按钮点击时触发的事件,该事件为 Page 级别事件,可以使用 QN.on 进行监听,注意 tapEvent 不要与其他事件重复 |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
iconImg
示例:
类型 |
示例 |
备注 |
URL |
http://www.icon.com/share.png |
|
URL |
https://www.icon.com/share.png |
|
Base64 |
iVBORw0KGgoAAAANSUhEUgAAAgAAAA... |
|
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.addButton({
query: {
iconName: 'share',
text: '分享',
tapEvent: 'Page.share', // 或 `share`
}
}).then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.addButton({
query: {
iconName: 'share',
text: '分享',
tapEvent: 'Page.share', // 或 `share`
},
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.removeButton(options)
移除导航栏自定义按钮
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.query |
Object |
|
|
接口调用参数 |
options.query.tapEvent |
String |
|
|
需要移除的按钮对应的事件(由于按钮事件事件是唯一的,因此也作为移除按钮的标识) |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.removeButton({
query: {
tapEvent: 'Page.share', // 或 `share`
}
}).then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.removeButton({
query: {
tapEvent: 'Page.share', // 或 `share`
},
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.clearButtons(options)
清除导航栏自定义按钮
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.clearButtons();
QN.navigator.clearButtons()
.then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.clearButtons({
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.addMenuItem(options)
添加导航栏菜单列表中自定义菜单项
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.query |
Object |
|
|
接口调用参数 |
options.query.iconName |
String |
|
|
千牛客户端内置 icon 名称,内置 icon 列表参看本页附录 |
options.query.iconImg |
String |
|
|
图标图片,URL 或 Base64 (暂不支持 URL) |
options.query.text |
String |
可选 |
|
图标文本,如果 iconName 和 iconImg 都没有值,则展示文本 |
options.query.tapEvent |
String |
|
|
按钮点击时触发的事件,该事件为 Page 级别事件,可以使用 QN.on 进行监听,注意 tapEvent 不要与其他事件重复 |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
iconImg
示例:
类型 |
示例 |
备注 |
URL |
http://www.icon.com/share.png |
|
URL |
https://www.icon.com/share.png |
|
Base64 |
iVBORw0KGgoAAAANSUhEUgAAAgAAAA... |
|
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.addMenuItem({
query: {
iconName: 'share',
text: '分享',
tapEvent: 'Page.share', // 或 `share`
}
}).then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.addMenuItem({
query: {
iconName: 'share',
text: '分享',
tapEvent: 'Page.share', // 或 `share`
},
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.removeMenuItem(options)
移除导航栏菜单列表中自定义菜单项
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.query |
Object |
|
|
接口调用参数 |
options.query.tapEvent |
String |
|
|
需要移除的按钮对应的事件(由于按钮事件事件是唯一的,因此也作为移除按钮的标识) |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.removeMenuItem({
query: {
tapEvent: 'Page.share', // 或 `share`
}
}).then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.removeMenuItem({
query: {
tapEvent: 'Page.share', // 或 `share`
},
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
QN.navigator.clearMenuItems(options)
清除导航栏菜单列表中自定义菜单项
API 调用入参
参数名 |
类型 |
是否可选 |
默认值 |
含义 |
options |
Object |
|
|
选项 |
options.success |
Function |
可选 |
|
调用成功的回调函数 |
options.error |
Function |
可选 |
|
调用失败的回调函数 |
API 响应结果
参数名 |
类型 |
是否必须返回 |
含义 |
result |
Object |
|
响应对象 |
result.code |
String |
|
错误码,成功为 QAP_SUCCESS ;失败为其他 |
result.msg |
String |
|
错误信息 |
调用示例
QN.navigator.clearMenuItems();
QN.navigator.clearMenuItems()
.then(result => {
console.log(result);
}, error => {
console.log(error);
});
QN.navigator.clearMenuItems({
success(result) {
console.log(result);
},
error(error) {
console.log(error);
}
});
FAQ
关于此文档暂时还没有FAQ