简化赋值

master
yutent 2023-11-22 12:50:40 +08:00
parent 24095297a5
commit e691868a55
1 changed files with 5 additions and 6 deletions

View File

@ -161,10 +161,9 @@ class Progress extends Component {
return Math.max(0, Math.min(val, 100)) return Math.max(0, Math.min(val, 100))
} }
#drawCircle() { #drawCircle(v) {
let offset = OFFSET[this.type] let offset = OFFSET[this.type]
let dash = DASH_ARRAY[this.type] let dash = DASH_ARRAY[this.type]
let v = this.value
return html` return html`
<svg viewBox="0 0 128 128"> <svg viewBox="0 0 128 128">
<path <path
@ -185,8 +184,7 @@ class Progress extends Component {
` `
} }
#drawLine() { #drawLine(v) {
let v = this.value
return html` return html`
<div class="progress-bar"> <div class="progress-bar">
<mark class="thumb" style=${styleMap({ width: v + '%' })}></mark> <mark class="thumb" style=${styleMap({ width: v + '%' })}></mark>
@ -198,10 +196,11 @@ class Progress extends Component {
} }
render() { render() {
let step = ~~(this.value / 20) || 1 let v = this.value
let step = ~~(v / 20) || 1
return html` return html`
<main class="container" step=${step}> <main class="container" step=${step}>
${this.type === TYPE_LINE ? this.#drawLine() : this.#drawCircle()} ${this.type === TYPE_LINE ? this.#drawLine(v) : this.#drawCircle(v)}
</main> </main>
` `
} }