1、预览

2、实现
<template> <div class="text-input-cell-wrapper" :style="textInputSty"> <textarea class="text-input-sty" :disabled="disableInput" :value="textValue" :placeholder="defaultvalue" @input="changeValue" :maxlength="maxCount" /> <span class="count">{{ this.count }}/{{ maxCount }}</span> </div></template><script>import Vue from 'vue';export default Vue.extend({ name: 'TextInputCell', props: { textInputSty: '', desc: '', disableInput: false, value: '', defaultvalue: '', maxCount: { default: 100, type: Number, }, }, data: function () { return { textValue: '', count: 0, }; }, created() { this.$nextTick(() => { this.textValue = this.value; }); }, // computed: { // countFun: function (e) { // return (this.textValue && this.textValue.length) || 0; // }, // }, watch: { textValue(newVal, oldVal) { this.count = (newVal && newVal.length) || 0; }, }, methods: { changeValue(e) { this.$nextTick(() => { this.textValue = e.target.value; this.$emit('input', event.target.value); }); }, },})</script><style lang="scss" scoped>.text-input-cell-wrapper { height: 55px; background: #fff; display: flex; line-height: 55px; justify-content: space-between; padding: 0 15px; box-sizing: border-box; position: relative; .text-input-sty { overflow: hidden; resize: none; width: 100%; text-align: left; font-size: 14px; border: 0; float: right; line-height: 30px; padding: 10px; } .text-input-sty::-webkit-input-placeholder { color: #acb7ce; font-size: 14px; font-family: 'PingFang FC'; } .text-input-sty:disabled { background: #fff; } .text-input-sty:focus { outline: none; border: 0; } .count { position: absolute; color: #a2adb6; font-size: 13px; right: 10px; bottom: 0px; }}</style>
3、使用
import TextInputCell from './components/TextInputCell'...components: { TextInputCell}...<TextInputCell defaultvalue="添加备注(选填)" textInputSty="height: 176px; width:100%;margin-bottom:10px;margin-bottom:28px;" :maxCount="100" v-model="remark" />