Intact实例方法

    • @param key 属性名
    • @param value {*} 属性值
    • @param options {Object} 选项
    • @return this
    • @example

    set(obj[, options])

    • @param obj {Object} 批量设置的属性对象
    • @param options {Object} 选项
    • @return this
    • @param
      1. this.set({a: 1, b: '2'});

    get

    获取实例数据

    get(key)

    • @param key 要获取的属性名
    • @return {*}
    • @example

    get()

    • @return {*} 返回实例所有数据

    on

    绑定组件的事件,详见

    on(eventName, callback)

    • @param eventName {String} 事件名
    • @param callback 事件处理函数
    • @return this
    • @example
      1. this.on('$change:a', function(c, newValue, oldValue) {
      2. console.log(newValue, oldValue);
      3. });

    one

    绑定组件的事件,与on()不同之处在于,事件回调触发后,立即解绑

    • @param callback {Function} 事件处理函数
    • @return this
    • @example

    off()

    解绑所有事件

    • @return this

    off(eventName)

    解绑所有eventName事件

    • @param eventName {String} 要解绑的事件名
    • @return this

    off(eventName, callback)

    解绑指定事件名下指定的事件处理函数

    • @param eventName {String} 要解绑的事件名
    • @param callback {Function} 要解绑的事件处理函数
    • @return this
    • @example
      1. var callback = function() {};
      2. this.on('$change:a', callback);

    trigger

    触发事件

    trigger(eventName[, …args])

    • @param eventName {String} 要触发的事件名
    • @param args {*} 传给事件处理函数的数据
    • @return this
    • example

    toString

    将组件渲染成字符串,一般用于服务器端渲染

    • @return {String}
    • @example
      1. // 将上面的第一个App渲染成字符串
      2. var app = new App();
      3. console.log(app.toString()); // <div>Intact</div>

    init

    init()

    • @return {HtmlElement}

    触发组件_mount生命周期

    mount()

    • @return {undefined}

    update

    使组件强制更新界面,触发_beforeUpdate_update生命周期

    update()

    destroy

    销毁组件,触发_destroy生命周期

    destroy()

    • @return {undefined}

    _initMountedQueue

    用于组件生命周期中,给组件绑定后才执行的函数,初始化一个队列,详见Intact实例#创建实例

    执行上述队列中的函数