Skip to content

ui-ruler has an error,when value="0" min="-200" max="200" #33

@microestc

Description

@microestc

Error Code: at ui-ruler
ready () {
if (this.data.value) { //当 0 时,错误
this.data.selfValue = Number(this.data.value) - this.data.selfMin
} else {
this.data.selfValue = 0
}

this.data.leftForSure = this.data.selfValue * (this.data.selfLineWidth + this.data.selfStepWidth)

this.setData({
  selfValue : this.data.selfValue,
  leftForSure: this.data.leftForSure
})

},
Pass Code:
ready () {
if (this.data.value != null) {
this.data.selfValue = Number(this.data.value) - this.data.selfMin
} else {
this.data.selfValue = 0
}

this.data.leftForSure = this.data.selfValue * (this.data.selfLineWidth + this.data.selfStepWidth)

this.setData({
  selfValue : this.data.selfValue,
  leftForSure: this.data.leftForSure
})

},
attached () {
this.data.lineHeight = this.data.lineHeight || Number(this.data.height) / 4
this.data.keyLineHeight = this.data.keyLineHeight || Number(this.data.lineHeight) * 2

this.data.selfValueStyle = StyleHelper.getPlainStyle(this.data.valueStyle)

this.data.selfStepWidth = Number(this.data.stepWidth)
this.data.selfLineWidth = Number(this.data.lineWidth)
this.data.selfMin = Number(this.data.min)
this.data.selfMax = Number(this.data.max)
this.data.value = this.data.value
this.data.step = Number(this.data.step)
this.data.keyStep = Number(this.data.keyStep)
this.data.pointerWidth = Number(this.data.pointerWidth)
this.data.selfWidth = Number(this.data.width)
if (this.data.width) {
  this.data.selfWidth = Number(this.data.width)
} else {
  this.data.selfWidth = wx.getSystemInfoSync().windowWidth
}
this.data.padding = this.data.selfWidth / 2

if (!this.data.numberPadding) {
  this.setData({
    numberPadding: this.data.numberSize / 2,
  })
} else {
  this.setData({
    numberPadding: this.data.numberPadding,
  })
}
this.setData({
  lineHeight: this.data.lineHeight,
  keyLineHeight: this.data.keyLineHeight,
  selfValueStyle: this.data.selfValueStyle,
  selfStepWidth: this.data.selfStepWidth,
  selfLineWidth: this.data.selfLineWidth,
  selfMin: this.data.selfMin,
  selfMax: this.data.selfMax,
  value: this.data.value,
  step: this.data.step,
  keyStep: this.data.keyStep,
  pointerWidth: this.data.pointerWidth
})
this.setData({
  padding: this.data.padding,
  rulerWrapStyle: OTS(this.rulerWrapStyleObj()),
  rulerStyle: OTS(this.rulerStyleObj()),
  rulerPointerStyle: OTS(this.rulerPointerStyleObj()),
  scrollViewStyle: OTS(this.scrollViewStyleObj()),
  rulerPaddingStyle: OTS(this.rulerPaddingStyleObj()),
  numberPaddingStyle: OTS(this.numberPaddingStyleObj())
})

},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions