【问题标题】:Vue3 How to pass input's value to method in @change="func(param)"?Vue3如何将输入值传递给@change =“func(param)”中的方法?
【发布时间】:2022-01-09 17:56:33
【问题描述】:

我有一个输入字段,每次更改值时都需要调用该函数并将新值传递给该函数。我找不到怎么做。

<template slot-scope="scope">
    <el-input
    type="text"
    :value="scope.row.name"
    v-model="queryName"
    @change="changeQueryName(scope.row.id, ???.queryName)">
    </el-input>
</template>

【问题讨论】:

    标签: javascript vue.js vuejs3


    【解决方案1】:

    您可以通过$event

    @change="changeQueryName($event, scope.row.id, ???.queryName)"
    

    这是文档HTMLElement: Event

    changeQueryName()函数中你可以使用event.target.value

    changeQueryName(event, id, queryName) {
       console.log(event.target.value)
    }
    

    【讨论】:

      猜你喜欢
      • 2020-08-04
      • 1970-01-01
      • 2017-08-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-11-14
      相关资源
      最近更新 更多