12345678910111213141516171819202122232425262728293031323334353637383940414243 |
- <template>
- <u--textarea v-bind="__attrs" v-on="__listeners"></u--textarea>
- </template>
- <script>
- import uProps from 'uview-ui/components/u-textarea/props';
- export default {
- name: 'cTextarea',
- props: {
- ...uProps.props,
- },
- computed: {
- __attrs() {
- return {
- ...this.$props,
- ...this.$attrs,
- placeholder: this.$props.placeholder || '请输入',
- };
- },
- __listeners() {
- return {
- ...this.$listeners,
- blur: this.onBlur,
- };
- },
- },
- methods: {
- onBlur() {
- const val = this.value;
- if (/^\s+$/.test(val)) {
- const modelValue = val.trim();
- this.$emit('input', modelValue); // v-model使用的是input事件
- this.$emit('blur', modelValue);
- return;
- }
- this.$emit('blur', val);
- },
- },
- };
- </script>
- <style scoped></style>
|