提交 88104047 编写于 作者: H hdx

fix(calendar): 减少一些不必要的绘制交互,尤其是在for循环中

上级 6151b92c
......@@ -158,6 +158,9 @@ export default {
const num = date_header_map.length
const one_width = width / num
ctx.font = '12'
ctx.textAlign = 'center'
for (let i = 0; i < num; i++) {
let box_left = i * one_width + 2
let box_width = one_width - 4
......@@ -167,8 +170,7 @@ export default {
const text = date_header_map[i]
let text_left = box_width / 2 + box_left
let text_top = box_height / 2 + 6
ctx.font = '12'
ctx.textAlign = 'center'
ctx.fillText(text, text_left, text_top)
ctx.update()
}
......@@ -192,6 +194,8 @@ export default {
ctx.reset()
}
ctx.textAlign = 'center'
for (let week = 0; week < week_len; week++) {
const week_item = weeks[week]
......@@ -207,9 +211,7 @@ export default {
let text_left = day * one_width + (one_width / 2)
let text_top = one_height * week + 25
ctx.font = '16'
ctx.textAlign = 'center'
// 日期是否禁用
if (day_item.disabled) {
......@@ -250,9 +252,7 @@ export default {
let lunar_left = day * one_width + (one_width / 2)
let lunar_top = one_height * week + 42
ctx.font = '10'
ctx.textAlign = 'center'
ctx.fillText(text, lunar_left, lunar_top)
}
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册