bui.hint Class
Constructor
bui.hint
-
[option]
Parameters:
-
[option]
Object optional-
appendTo
String[ 在某个容器内 例如:#page ]
-
content
String[ 提醒的内容,没有内容只是引用,不执行 ]
-
skin
String[ 1.5.0新增, 默认:"" | warning | primary | success | danger ]
-
effect
String[ 动画效果,参考toggle ]
-
timeout
Number[ 多少秒后消失 单位:ms ]
-
autoClose
Boolean[ 是否自动关闭 默认true | false ]
-
position
String[ bottom | top ]
-
[onBeforeInit]
Function optional[ 1.5.1新增 初始化前触发 ]
-
[onInited]
Function optional[ 1.5.1新增 初始化以后触发 ]
-
onClose
Function[ 回调 ]
-
Example:
方法1: 快速提醒
bui.hint("确定会删除信息,不可还原");
方法2: 可以修改更多参数
bui.hint({
appendTo: "",
content: "",
timeout: 2000,
autoClose: false, //不开启倒计时
position: "bottom", // bottom || top
onClose: null
})
方法2: 居中提醒示例
bui.hint({
content:"
欢迎使用BUI",
position:"center" ,
effect:"fadeInDown"
});
Methods
destroy
-
[bool]
[销毁控件]
Parameters:
-
[bool]
Boolean optional[ 默认: false 销毁部分 | true 销毁全部 ]
Example:
//销毁
uiHint.destroy();
hide
-
text
隐藏提醒
Parameters:
-
text
String[提醒的文本]
Example:
var uiHint = bui.hint({ "content": "提醒的信息", "autoClose": true});
//如果一直存在,就需要手动关闭了
uiHint.hide();
init
-
[option]
初始化方法,用于重新初始化结构,事件只初始化一次
Parameters:
-
[option]
Object optional[参数控件本身]
isShow
()
chainable
当前的显示状态
Example:
var uiHint = bui.hint("提醒的信息");
uiHint.isShow();
option
-
[key]
-
[value]
获取设置参数
Parameters:
-
[key]
String | object optional[ 不传则获取所有参数, 类型为string,没有第2个参数则获取某个参数 ]
-
[value]
String | number | boolean | function optional[ 设置参数的时候要传,设置多个参数不用传,获取参数的时候也不用传 ]
Example:
//获取所有参数
//获取所有参数
var option = uiHint.option();
//获取某个参数
var id = uiHint.option( "appendTo" );
//修改一个参数
uiHint.option( "autoClose",true );
//修改多个参数
uiHint.option( {"autoClose":true} );
remove
-
text
新增提醒
Parameters:
-
text
String[提醒的文本]
Example:
var uiHint = bui.hint("提醒的信息");
uiHint.remove();
show
-
text
显示提醒
Parameters:
-
text
String[提醒的文本]
Example:
var uiHint = bui.hint({ "content": "提醒的信息", "autoClose": true});
//如果一直存在,就需要手动关闭了
uiHint.show();
widget
-
[name]
获取依赖的控件
Parameters:
-
[name]
String optional[ 依赖控件名 toggle ]
Example:
//获取依赖控件
var uiHintWidget = uiHint.widget();
Events
off
为控件取消绑定事件
Event Payload:
-
[type]
String optional[ 事件类型: "show" | "hide"(隐藏或者移除时) ]
-
[callback]
Function optional[ 绑定的事件, this 为当前点击的菜单 ]
Example:
uiHint.off("show");
on
为控件绑定事件
Event Payload:
-
[type]
String optional[ 事件类型: "show" | "hide"(隐藏或者移除时) ]
-
[callback]
Function optional[ 绑定的事件, this 为当前点击的菜单 ]
Example:
uiHint.on("show",function () {
// 点击的菜单
console.log(this);
});