vue.js - 动态数据分配不适用于 Vue js
问题描述
所以我有这段代码,它循环遍历this.product.taxons
每个元素,它查看对象数组this.taxons
以找到taxon
具有相同值的 。
this.product.taxons.forEach((taxon) => {
// taxon = 'bed_sheet'
const data = this.taxons.find((x) => x.value === exclusion);
// data = {
// value: 'bed_sheet',
// model: 'bedSheet'
// }
this.currentProduct.`${data.model}` = true; // this does not work.
});
但我的问题this.currentProduct.'${data.model}' = true;
是翻译成this.currentProduct.bedSheet = true;
并以任何其他方式返回错误SyntaxError: Unexpected token
来实现这一点?
解决方案
推荐阅读
- java - 有没有办法在方法参数中将 Java 代码片段作为 Groovy Closure 传递?
- javascript - PageObjects:如何在另一个函数中调用一个函数?
- python - itertools.product 如何在不将中间结果保存在内存中的情况下计算笛卡尔积
- r - 有条件的 tidyr::complete() 到变量最大值
- c# - 如何在 C# 中计算文本文件中的字符串
- javascript - 取决于媒体查询的通用参数
- php - 从控制器到视图的空数组 - Laravel
- kubernetes - 在实时和未来节点上配置 kubelet
- pick - 如何运行带参数的程序(Pick BASIC)
- python - 使用 lxml 进行迭代解析期间无法识别的标签