Kaynağa Gözat

拼音效果单独居中

zq 1 ay önce
ebeveyn
işleme
aa1013bf3c
1 değiştirilmiş dosya ile 11 ekleme ve 2 silme
  1. 11 2
      src/components/PinyinText.vue

+ 11 - 2
src/components/PinyinText.vue

@@ -15,7 +15,11 @@
           v-if="block.type === 'text'"
           :key="'text-' + index"
           class="pinyin-sentence"
-          :style="[{ 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' }, block.sentenceStyle]"
+          :style="[
+            { 'align-items': pinyinPosition === 'top' ? 'flex-end' : 'flex-start' },
+            block.sentenceStyle,
+            block.parentStyle,
+          ]"
         >
           <span
             v-for="(word, wIndex) in block.word_list"
@@ -688,7 +692,11 @@ export default {
         sentenceStyle.paddingLeft = styleObj.paddingLeft;
         delete styleObj.paddingLeft;
       }
-
+      let parentStyle = {};
+      if (styleObj && styleObj.textAlign === 'center') {
+        parentStyle['text-align'] = 'center';
+        parentStyle['display'] = 'block';
+      }
       return {
         type: 'text',
         word_list: item.word_list,
@@ -699,6 +707,7 @@ export default {
         sentenceStyle,
         rawStyleText: combinedStyle,
         hasEmphasisDot,
+        parentStyle,
       };
     },