You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
50 lines
1.4 KiB
50 lines
1.4 KiB
import classNames from '../common/classNames'
|
|
|
|
Component({
|
|
properties: {
|
|
prefixCls: {
|
|
type: String,
|
|
value: 'wux-skeleton',
|
|
},
|
|
active: {
|
|
type: Boolean,
|
|
value: true,
|
|
observer: 'updated',
|
|
},
|
|
},
|
|
data: {
|
|
classes: null
|
|
},
|
|
lifetimes: {
|
|
// 生命周期函数,可以为函数,或一个在methods段中定义的方法名
|
|
attached: function () {
|
|
this.setData({
|
|
classes: this.initwrap(this.data.prefixCls, this.data.active)
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
initwrap: function(prefixCls, active){
|
|
const wrap = classNames(prefixCls, {
|
|
[`${prefixCls}--active`]: active,
|
|
})
|
|
return {
|
|
wrap,
|
|
}
|
|
},
|
|
updated(active = this.data.active) {
|
|
const avatar = this.getRelationNodes('../skeleton-avatar/index')
|
|
const paragraph = this.getRelationNodes('../skeleton-paragraph/index')
|
|
if (avatar && avatar.length > 0) {
|
|
avatar.forEach((element) => {
|
|
element.updated(active)
|
|
})
|
|
}
|
|
if (paragraph && paragraph.length > 0) {
|
|
paragraph.forEach((element) => {
|
|
element.updated(active)
|
|
})
|
|
}
|
|
},
|
|
},
|
|
})
|