javascript - 我有不会添加的数字(我必须保留为字符串)。他们只是连接数字
问题描述
这是 HTML 和 JS 或我的字段的副本。我必须保留这个字符串,那么我该如何解析和加/减呢?或者有什么方法可以翻转到数字然后返回到字符串?不确定在不更改为数字/整数的情况下解决此问题的最佳方法。
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group">
<label>Total Sum Due <span class="note">2</span></label>
<input type="text" class="form-control" v-model="document.money_due" placeholder="">
</div>
</div>
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group">
<label>First Month (in USD) <span class="note"></span></label>
<input type="text" class="form-control" v-model="document.first_month" placeholder="">
<p-check class="p-svg p-curve m-2" color="success" v-on:change="paidFirstMonth" v-model="document.is_first_month" value="1">
<svg slot="extra" class="svg svg-icon" viewBox="0 0 20 20"><path d="z" style="stroke: white;fill:white"></path></svg>
<label>PAID</label>
</p-check>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group">
<label>Last Month (in USD) <span class="note"></span></label>
<input type="text" class="form-control" v-model="document.last_month">
<p-check class="p-svg p-curve m-2" color="success" @change="paidLastMonth" v-model="document.is_last_month" value="1">
<svg slot="extra" class="svg svg-icon" viewBox="0 0 20 20"><path d="" style="stroke: white;fill:white"></path></svg>
<label>PAID</label>
</p-check>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-4">
<div class="form-group">
<label>Security Deposit (in USD) <span class="note"></span></label>
<input type="text" class="form-control" @change="hasSecurity" v-model="document.security_deposit" value="1">
<p-check class="p-svg p-curve m-2" color="success" @change="paidSecurity" v-model="document.is_security_deposit" value="1">
<svg slot="extra" class="svg svg-icon" viewBox="0 0 20 20"><path d="" style="stroke: white;fill:white"></path></svg>
<label>PAID</label>
</p-check>
</div>
</div>
</div>
data() {
return {
now: new Date().toISOString(),
loaded: false,
document: {
first_month: '',
last_month: '',
security_deposit: '',
}
}
}
monthlyRent() {
if(this.document.lease_month != '') {
this.document.money_due = this.document.first_month + this.document.last_month +
this.document.security_deposit;
}
},
解决方案
推荐阅读
- javascript - 试图理解这个 JavaScript 重复删除算法中的 for 循环
- haskell - Set value of record field to calculation involving another field in same record
- reactjs - 将我的静态网站的 AWS 给定域更改为 godaddy 域
- angular - 如何为版本 7 更新 Angular 项目版本 5
- fortran - 如何将包含字符串的文本文件读入Fortran中的数组
- python - 如何仅获取与模式匹配的文件名
- swift - 视频缩略图被颠倒了
- sql-server - 我无法让我的 Microsoft SQL Server 触发器正常运行
- forms - 使用 yup 和自定义验证来验证 react-final-form 表单
- vue.js - 如何将 BootstrapVue 在 Nuxt.js 中使用 Purgecss 所需的所有内容列入白名单