vue标签页tabs和codemirror一起使用

vue标签页tabs和codemirror一起使用时, codemirror 会变形

 

要注意tab切换时,codemirror必须刷新配置

<el-tabs v-model="configupload.upload_active" type="card" @tab-click="handleChangeImport">
    <el-tab-pane label="上传导入" name="upload">
        <el-upload
                class="upload-k8sconfig"
                ref="upload"
                action="string"
                :before-upload="beforeConfigUpload"
                :http-request="UploadConfig"
        >
            <el-button size="small" type="primary">点击上传</el-button>
            <div slot="tip" class="el-upload__tip">导入/etc/kubernetes/admin.conf文件</div>
        </el-upload>
    </el-tab-pane>
    <el-tab-pane label="输入导入" name="input">
        <codemirror ref="import_codemirror" v-model="configupload.config" :options="cmOptions"
                    class="sourcecode"/>
    </el-tab-pane>
</el-tabs>

......

<script>
...
      handleChangeImport(tab){
        if (tab.name === 'input') {
          this.$nextTick(() => {
            this.$refs.import_codemirror.codemirror.refresh();
          })
        }
      },
...
</script>

 

posted @ 2020-12-17 17:18  醒日是归时  阅读(709)  评论(0编辑  收藏  举报