javascript - 当我们向卡片添加 3 个产品时,我想在产品名称中添加 x 和 3?
问题描述
当我们向卡片添加 3 个产品时,我想在产品名称中添加x
和?3
例如:Product Name x 3
。
if(checkGreatrThan(quantity)){
tableRow +='<div class="prod-title-col order-summary-col2 '+lastIndex+'"><h3 class="prod-title" >'+ value.product_name + '<span>'+ 'x '+value.quantity+'</span>+'</h3></div>' ;
}
else {
tableRow +='<div class="prod-title-col order-summary-col2 '+lastIndex+'"><h3 class="prod-title" >'+ value.product_name +'</h3></div>';
}
你能格式化声明吗?
解决方案
我假设您的变量已定义。
您的问题是,您在第一次添加 tableRow 时有一些 ' 和 + 太多。所以你的javascript抛出了那个错误。
if(checkGreatrThan(quantity)){
tableRow +='<div class="prod-title-col order-summary-col2 '+lastIndex+'"><h3 class="prod-title" >'+ value.product_name + '<span>x '+value.quantity+'</span></h3></div>' ;
}
else {
tableRow +='<div class="prod-title-col order-summary-col2 '+lastIndex+'"><h3 class="prod-title" >'+ value.product_name +'</h3></div>';
}
推荐阅读
- disk - 更换 DRBD 中的故障驱动器 ()
- javascript - 反应:this.props.item 未定义
- sql - 左连接的意外结果
- python-3.x - Pandas 查找间隔(n 天)并捕获开始/结束日期
- flutter - 如何将 C++ cv::Mat 转换为 Flutter 变量?
- json - 如何将 Excel 转换为 csv 到 Json(没有文本数字转换为数字)?
- protocol-buffers - protoc命令中--plugin参数的作用是什么
- windows - 复制到网络共享不适用于 powershell Copy-Item
- azure - 如何使用 Azure CLI 从 azure Active Directory 获取最近创建的 AD 用户列表
- javascript - jQuery - 复选框不更新文本