el-input carriage return will automatically refresh the page reason and solution

problem causes:

When there is only one input box in the form, press Enter in the input box to submit the form and automatically refresh the page. It's good to know the reason.

Solution:

Adding @submit.native.prevent to prevent the original submission event is to prevent the default refresh page, but the carriage return event will still be triggered.

<el-form @submit.native.prevent>

Method explanation:

@submit.native.prevent

submit, as the name implies, is to submit

.native means to bind the original event of the system to a component

.prevent means that the page will not be refreshed after submission

el-input binds keyboard enter event

<el-input type="textarea" class="talk-textarea" v-model="message"
          @keyup.enter.native="enterFun">
</el-input>

Guess you like

Origin blog.csdn.net/qq_43631129/article/details/130429698