How does vue dispatch a publication order to submit a submit event

<template>
  <el-container>
    <form action="/api/exportExcel">
      <input type="text" name="userid">
    </form>

    <!-- buttonform -->
    <button @click="onSubmit"></button>
  </el-container>
<template>
<script>
export default {
  methods: {
    exportExcel () {
      document.getElementById("expformsubmit").submit()
    }
  }
}
</script>

button is placed outside the form. How do I submit events after clicking on this button?
because the result is to action jump after form.submit () to generate the next excel file, ajax is not used.

the above code has been implemented, but if you use vue, you usually refuse to operate with DOM, right? So I want to know the solution based on vue.


this kind of dispatch event operation still uses the DOM operation, but VUE can do this.
add ref= "xxxx" to the form tag , and then use this.$refs.xxxx access in JS without tag search functions. For more information, please see

Previous: How to realize dynamic attribute assignment in yii2

Next: Why does the foreach loop affect the entire large array?

Menu