Invalid Vue @ click solution

this click is invalid, whether or not to add the native modifier, or whether to add parentheses after test.

this p tag can be clicked, and there are no syntax errors in the code.

clipboard.png

the code is as follows:

<template>
  <div class="add_wrap">
    

<form id="add_contact"> <div class="avatar_area">

<input type="file" name="avatar" hidden> </div> <div class="input_list">

<span class="left"></span> <input type="text" name="name">

<span class="left"></span> <input type="text" name="mobile">

<span class="left"></span> <input type="text" name="telephone">

<span class="left"></span> <input type="text" name="email">

<span class="left"></span> <input type="text" name="company">

<span class="left"></span> <input type="text" name="title">

<span class="left"></span> <input type="text" name="fax">

</div> </form> <p class="add_my_field">

<p @click.native="test">

</div> </template> <script> import global_ from "@/components/Global"; export default { name: "app-add", data() { return { thisId: undefined, preField: global_.preField }; }, methods: { test() { console.log(111); let form = document.querySelector("-sharpadd_contact"); let now_data = new FormData(form); console.log(now_data); } } }; </script>

refers to a component Global, that holds global constants but does not actually use it. The data in data is also not used. No error was reported when compiling and running with vue-cli,.

Sep.29,2021

try the event modifier and take a look at the usage of .native


< H2 > can you expand your data and have a look < / H2 >

add:
https://codepen.io/anon/pen/q.
I wrote an example. It is true that the click event does not trigger after adding the native modifier, but it is possible when it is not added.


first of all .native is generally used for custom tags. Many frameworks disable native event click. .native

from the code, console.log (111) is the second output that can be outputted. You need to add $nextTick to monitor that dom has been rendered

if you need to get $nextTick by getting dom.

I copied your code and tried to get rid of .native. Isn't that all right? make sure you click right. Change p to button, is not easy to read wrong, and then click to see

.
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e4d6e3-44f33.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e4d6e3-44f33.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?