javascript - Set Component props on click
问题描述
I have a button that references to a specific data, then I want to add a component with a props specific to the data that is referenced to that button.
<MyComponent v-bind:props="mydata[0]"/>
that is basically what I'm doing, let say I want to bind a props mydata[1]
instead of mydata[2]
without typing it manually on the template, I want the props to be dynamic. thanks in advance
解决方案
define a variable called index in data, and change that variable on that button click to the specific index, something like this
<v-btn @click="index = 1">display data of 1</v-btn>
and
<MyComponent v-bind:props="mydata[index]"/>
推荐阅读
- r - 关于 h2o.grid() 函数中的并行性的问题
- mysql - SQL 错误 [1054][42s22]: 未知列 'orderdetails.productCode in 'on 子句'
- html - 使用引导程序在同一行中添加文本和图像
- java - 所需的请求部分“文件”不存在,但设置可能正确
- bash - Bash 的“声明”的未记录的“-c”选项?
- mysql - 过程中更新查询的重复输入错误
- hydra - 在装饰器中设置 Hydra 默认配置
- javascript - then方法中的代码不执行,进行错误处理
- arrays - 我相信我做了一个无限循环,但我不知道它是在哪里创建的
- python - 在模板中收到来自 Ajax 的发布请求后,Flask 无法重定向