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.
63 lines
1.5 KiB
63 lines
1.5 KiB
import classNames from '../common/classNames'
|
|
|
|
Component({
|
|
options: {
|
|
addGlobalClass: true,
|
|
multipleSlots: true
|
|
},
|
|
properties: {
|
|
prefixCls: {
|
|
type: String,
|
|
value: 'wux-skeleton-paragraph',
|
|
},
|
|
rows: {
|
|
type: Number,
|
|
value: 3,
|
|
},
|
|
rounded: {
|
|
type: Boolean,
|
|
value: true,
|
|
},
|
|
widths: {
|
|
type: Array,
|
|
value: [],
|
|
}
|
|
},
|
|
data: {
|
|
active: true,
|
|
rowList: [],
|
|
},
|
|
lifetimes: {
|
|
attached: function () {
|
|
this.updateRows()
|
|
this.setData({
|
|
classes: this.initwrap(this.data.prefixCls, this.data.active, this.data.rounded)
|
|
})
|
|
}
|
|
},
|
|
methods: {
|
|
initwrap: function (prefixCls, active, rounded) {
|
|
const wrap = classNames(prefixCls, {
|
|
[`${prefixCls}--active`]: active,
|
|
[`${prefixCls}--rounded`]: rounded,
|
|
})
|
|
const row = `${prefixCls}__row`
|
|
return {
|
|
wrap,
|
|
row,
|
|
}
|
|
},
|
|
updated(active) {
|
|
if (this.data.active !== active) {
|
|
this.setData({
|
|
active,
|
|
})
|
|
}
|
|
},
|
|
updateRows(rows = this.data.rows) {
|
|
this.setData({
|
|
rowList: [...Array(rows)].map((_, index) => index),
|
|
})
|
|
},
|
|
}
|
|
})
|