Fetch the repository succeeded.
This action will force synchronization from Yaohaixiao/outline.js, which will overwrite any changes that you have made since you forked the repository, and can not be recovered!!!
Synchronous operation will process in the background and will refresh the page when finishing processing. Please be patient.
import isString from './utils/types/isString'
import hasOwn from './utils/lang/hasOwn'
import isObject from './utils/types/isObject'
import extend from './utils/lang/extend'
import publish from './utils/observer/emit'
import subscribe from './utils/observer/on'
import unsubscribe from './utils/observer/off'
class Base {
constructor(options) {
this.attrs = {}
if (options) {
this.initialize(options)
}
}
initialize(options) {
this.attr(options).render().addListeners()
return this
}
attr(prop, value) {
const attrs = this.attrs
if (isString(prop)) {
// 只能扩展 attrs 中已有的属性
if (value && hasOwn(attrs, prop)) {
// 更新单个配置信息
attrs[prop] = value
return this
}
// 只传递 prop 参数,则返回对应的属性值
return attrs[prop]
} else if (isObject(prop)) {
// 批量更新配置信息
extend(attrs, prop)
return this
} else if (arguments.length === 0) {
// 不传递参数,直接返回整个
return attrs
}
return this
}
render() {
return this
}
destroy() {
this.removeListeners()
return this
}
reload(options) {
this.destroy().initialize(this.attr(options))
return this
}
$emit(event, data) {
publish(event, data)
return this
}
$on(event, callback) {
subscribe(event, callback, this)
return this
}
$off(event, callback) {
unsubscribe(event, callback)
return this
}
addListeners() {
return this
}
removeListeners() {
return this
}
}
export default Base
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。