mirror of
https://github.com/jumpserver/lina.git
synced 2025-09-20 02:31:43 +00:00
perf: 优化markdown组件样式
This commit is contained in:
@@ -8,7 +8,7 @@
|
|||||||
</span>
|
</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<el-col :span="span">
|
<el-col :span="span" :style="{'height': height + 'px' }">
|
||||||
<el-input
|
<el-input
|
||||||
v-model="iValue"
|
v-model="iValue"
|
||||||
autosize
|
autosize
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
@change="onChange"
|
@change="onChange"
|
||||||
/>
|
/>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col v-if="isShow" :span="span">
|
<el-col v-show="isShow" :span="span">
|
||||||
<VueMarkdown class="result-html" :source="iValue" :show="true" :html="true" />
|
<VueMarkdown class="result-html" :source="iValue" :show="true" :html="true" />
|
||||||
</el-col>
|
</el-col>
|
||||||
</el-row>
|
</el-row>
|
||||||
@@ -49,11 +49,33 @@ export default {
|
|||||||
},
|
},
|
||||||
data() {
|
data() {
|
||||||
return {
|
return {
|
||||||
|
height: 0,
|
||||||
|
resizeObserver: null,
|
||||||
span: 12,
|
span: 12,
|
||||||
isShow: true,
|
isShow: true,
|
||||||
iValue: this.value
|
iValue: this.value
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
mounted() {
|
||||||
|
this.$nextTick(() => {
|
||||||
|
this.resizeObserver = new ResizeObserver(entries => {
|
||||||
|
// 监听高度变化
|
||||||
|
const height = entries[0].target.offsetHeight
|
||||||
|
if (height) {
|
||||||
|
this.height = height
|
||||||
|
}
|
||||||
|
})
|
||||||
|
const el = document.querySelector('.result-html')
|
||||||
|
this.resizeObserver.observe(el)
|
||||||
|
})
|
||||||
|
},
|
||||||
|
beforeDestroy() {
|
||||||
|
const el = document.querySelector('.result-html')
|
||||||
|
if (el) {
|
||||||
|
this.resizeObserver.unobserve(el)
|
||||||
|
}
|
||||||
|
this.resizeObserver = null
|
||||||
|
},
|
||||||
methods: {
|
methods: {
|
||||||
onChange() {
|
onChange() {
|
||||||
this.$emit('change', this.iValue)
|
this.$emit('change', this.iValue)
|
||||||
@@ -76,14 +98,17 @@ export default {
|
|||||||
font-size: 13px;
|
font-size: 13px;
|
||||||
}
|
}
|
||||||
|
|
||||||
>>> .el-textarea__inner {
|
>>> .el-textarea {
|
||||||
min-height: 210px !important;
|
height: 100% !important;
|
||||||
|
.el-textarea__inner {
|
||||||
|
min-height: 210px !important;
|
||||||
|
height: 100% !important;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
.source {
|
.source {
|
||||||
padding: 6px;
|
padding: 6px;
|
||||||
}
|
}
|
||||||
.result-html {
|
.result-html {
|
||||||
height: 100%;
|
|
||||||
min-height: 210px;
|
min-height: 210px;
|
||||||
margin-left: 4px;
|
margin-left: 4px;
|
||||||
padding: 5px 10px;
|
padding: 5px 10px;
|
||||||
|
Reference in New Issue
Block a user