Forráskód Böngészése

绘制前设置字体,否则tagWidth受前面的font fontStyle影响

lifanagju_citu 2 hónapja
szülő
commit
51d955bf1c

+ 1 - 3
components.d.ts

@@ -30,6 +30,7 @@ declare module 'vue' {
     CtTextField: typeof import('./src/components/CtVuetify/CtTextField/index.vue')['default']
     DatePicker: typeof import('./src/components/DatePicker/index.vue')['default']
     Echarts: typeof import('./src/components/Echarts/index.vue')['default']
+    ElCascader: typeof import('element-plus/es')['ElCascader']
     ElConfigProvider: typeof import('element-plus/es')['ElConfigProvider']
     Empty: typeof import('./src/components/Empty/index.vue')['default']
     File: typeof import('./src/components/Upload/file.vue')['default']
@@ -73,7 +74,4 @@ declare module 'vue' {
     VerifySlide: typeof import('./src/components/Verifition/Verify/VerifySlide.vue')['default']
     WangEditor: typeof import('./src/components/FormUI/wangEditor/index.vue')['default']
   }
-  export interface ComponentCustomProperties {
-    vLoading: typeof import('element-plus/es')['ElLoadingDirective']
-  }
 }

+ 2 - 1
src/views/recruit/components/jobFairEntShare/index.vue

@@ -101,6 +101,8 @@ const drawCanvas = () => {
         let tagY = textY + tagSpacing + 10
         props.positionList.forEach((tag) => {
           let truncatedTag = tag
+          ctx.font = '18px Arial' // 绘制前设置字体,否则tagWidth受前面的font fontStyle影响
+          
           while (ctx.measureText(truncatedTag + '...').width > maxTextWidth - 2 * tagPaddingLeftRight && truncatedTag.length > 0) {
             truncatedTag = truncatedTag.slice(0, -1)
           }
@@ -123,7 +125,6 @@ const drawCanvas = () => {
           ctx.closePath()
           ctx.fill()
 
-          ctx.font = '18px Arial'
           ctx.fillStyle = '#fff'
           ctx.fillText(truncatedTag, tagX + tagPaddingLeftRight, tagY + tagPaddingTopBottom + 10)