2 回答

TA貢獻(xiàn)1900條經(jīng)驗(yàn) 獲得超5個贊
您可以通過v模型輕松執(zhí)行此操作:
<textarea
id="e-textarea"
class="form-control"
row="3"
v-model="value"
>
</textarea>
它等于:
<textarea
id="e-textarea"
class="form-control"
:value="value"
@input="value = $event.target.value"> </textarea>

TA貢獻(xiàn)1828條經(jīng)驗(yàn) 獲得超6個贊
綁定自定義和事件中的值:textareainput
CustomTextarea.vue
<template>
<div class="form-group">
<label for="e-textarea">{{ title }}</label>
<textarea
id="e-textarea"
class="form-control"
row="3"
v-bind:value="value"
v-on:input="$emit('input', $event.target.value)"
>
</textarea>
</div>
</template>
<script>
import { FormGroupInput } from "@/components/NowUiKit";
export default {
name: "e-textarea",
components: {
[FormGroupInput.name]: FormGroupInput
},
model: {
prop: "textAreaVue"
},
props: {
title: String,
value: String
},
computed: {
listenerFunction() {
return {
...this.$listener,
input: this.updateValue
};
}
},
methods: {
updateValue(value) {
console.log("function has been passed");
this.$emit("input", value);
}
},
mounted() {
console.log(this.components);
}
};
</script>
<style src="@/assets/styles/css/input.css" />
并將其與以下各項(xiàng)一起使用:v-model
<custom-textarea
title="Informations complémentaires"
v-model="otherInformation"></custom-textarea>
添加回答
舉報(bào)