Vue element button

<el-button type="primary" @click="btn1" :data-value="btnarray.btn1" native-type="button"></el-button>
data() {
      return {
        btnarray:{
            btn1:"",
            btn2:""
        }
      }
    },

if you want to assign a value to the button, get the value of the button when you click it. But why do you get this value sometimes and undefined

sometimes?

sometimes the result is this:

clipboard.png

:

clipboard.png

Feb.12,2022

using vue is not recommended to operate dom, you want to click to get the value of the button, as far as possible to use the method of passing parameters.

<el-button type="primary" @click="btn1(btnarray.btn1)" :data-value="btnarray.btn1" native-type="button"></el-button>
export default {
    data () {
        return {
            ...
        }
    },
    methods: {
        btn1 (value) {
            console.log(value) //
        }
    }
}

do not operate dom, with vue. Do not use the thinking of the jquery era. You can add a variable directly to data

.
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-1b4c933-2cb3d.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-1b4c933-2cb3d.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?