Commit a8d78507 by 姜鹏凯

欢迎语支持换行

1 parent 2b230186
// 带 插入 表情/客户昵称 等扩展工具栏的文本内容框 // 带 插入 表情/客户昵称 等扩展工具栏的文本内容框
<script> <script>
export default { export default {
name: '', name: '',
props: { props: {
value: '', value: '',
// ['emoji','insertCustomerNickName'] // ['emoji','insertCustomerNickName']
toolbar: { toolbar: {
type: Array, type: Array,
default: () => ['emoji'], default: () => ['emoji']
}
}, },
}, components: {
components: { SelectEmoji: () => import('@/components/SelectEmoji')
SelectEmoji: () => import('@/components/SelectEmoji'),
},
data() {
return {}
},
computed: {
proxyValue: {
get() {
return this.value
},
set(val) {
this.$emit('input', val)
},
}, },
}, data() {
watch: {}, return {}
created() {},
mounted() {},
methods: {
// 插入内容
insertContent(value) {
const $textarea = this.$refs.textarea.$el.children[0]
const content = this.proxyValue || ''
const textIndex = $textarea.selectionStart
this.proxyValue = content.slice(0, textIndex) + value + content.slice(textIndex)
}, },
}, computed: {
} proxyValue: {
get() {
return this.value
},
set(val) {
this.$emit('input', val)
}
}
},
watch: {},
created() {},
mounted() {},
methods: {
// 插入内容
insertContent(value) {
const $textarea = this.$refs.textarea.$el.children[0]
const content = this.proxyValue || ''
const textIndex = $textarea.selectionStart
this.proxyValue = content.slice(0, textIndex) + value + content.slice(textIndex)
}
}
}
</script> </script>
<template> <template>
...@@ -55,4 +55,8 @@ export default { ...@@ -55,4 +55,8 @@ export default {
</div> </div>
</template> </template>
<style lang="scss" scoped></style> <style lang="scss" scoped>
textarea {
white-space: pre-wrap; //保留所有空格
}
</style>
Markdown is supported
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!