我正在尝试使用产品的复选框(绑定到该复选框的产品价格)并从另一个输入中选择的数字中获取总价格,来计算商品的总价。但这不能按预期方式工作,因为当我单击第二个产品时,它的价格自动计算出来,而无需我选择所需的项目数。如何解决此问题,以便仅在提供数量时才计算总价?这是我的代码:
create table #sprocResult (
-- define columns that match the results of the sproc.
-- You should also define a PK, and possibly other indexes
)
insert into #sprocResult exec proc1
HTML
const vm = new Vue ({
el: "#app",
data: {
checkedValue: [],
amount: [],
items: [{name:"amazing", price:"2000"},
{name:"kulahappy", price:"1000"},
{name:"Yolo", price:"3000"}]
},
computed: {
totalPrice (){
const total = this.checkedvalue.reduce((acc, curr) => acc + parseInt(curr, 10), 0)
const number = this.amount.reduce((acc, curr) => acc + parseInt(curr, 10), 0)
const sum = total * number
return sum
}
}
})