javascript - 如何在 vue @click 事件中传递 Boolean:true?
问题描述
@click.native="scrollTo(index,true)"
我的期望:总是传递Boolean:true
给函数 scrollTo Vue 的反应:Vue 将true
其视为变量的名称,因此在 scrollTo 函数中,我得到了Number:index
andundefined
如何解决?
解决方案
my mistake.... I forgot there was another event @touchstart="scrollTo(index)"
ahead of @click.native="scrollTo(index,true)"
that's why I got undefined
in scrollTo function.
Yes. vue can pass Boolean:true
into function
推荐阅读
- java - 将捕获图像数据插入片段中的 ImageView 时出错
- reactjs - 将数字传递给反应js中的函数
- python - 我收到此错误---> TypeError: integer argument expected, got float
- sendgrid - Sendgrid 的链接产生无法建立安全连接
- windows - 在 ubuntu 上解压后文件名错误
- node.js - 如何在 Nestjs 中将 axios 内容从“text/html”更改为 application/json 类型
- java - Recyclerview 和 OkHttp 请求同步
- python-3.x - 为什么这个除法的结果是“inf”?
- docker - ARG 值是否传递给使用 RUN 执行的脚本
- jenkins - 从 jenkins 扩展选择参数中获取源值