naive-ui/demo/documentation/components/docCodeEditorMixin.js

14 lines
381 B
JavaScript
Raw Normal View History

2019-06-18 14:53:24 +08:00
export default {
mounted () {
2019-06-24 15:11:27 +08:00
const textAreaNotToRender = new Set(this.$refs.doc.querySelectorAll('.not-code textarea'))
2019-06-18 14:53:24 +08:00
this.$refs.doc.querySelectorAll('textarea').forEach(ta => {
2019-06-24 15:11:27 +08:00
if (textAreaNotToRender.has(ta)) {
return
}
const rows = ta.value.split('\n').length
ta.style.width = '100%'
ta.setAttribute('rows', rows)
2019-06-18 14:53:24 +08:00
})
}
}