javascript - 如何在Vue中的另一个函数的计算中使用函数返回值
问题描述
我在 Vue 中使用 laravel,并且刀片文件中有一个函数 updateTds,它返回接收到的 TDS,因此我需要使用 updateTds 函数中该文件模型中定义的函数的返回值来计算 TDS在那个数量上,但我不知道如何实现,有人可以帮助我理解吗?
This is the function in model file:
public function Amount()
{
$country = optional($this->client)->country;
$amount = $this->amount;
if ($this->client->type == 'indian') {
$amount = $this->amount + $this->gst;
}
return $amount . ' ' . optional($country)->currency_symbol;
} ```
and this is in view file(blade file):
@section('js_scripts')
<script>
new Vue({
el:'#form',
methods: {
updateTds() {
this.tds = this.amount - this.amount_paid
this.tds_percentage = (this.tds/this.amount) * 100
},
},
我想在 updateTds() 函数中使用从 Amount() 函数返回的金额。
Something like that:
updateTds() {
this.tds = this.amount(returned from Amount()) - this.amount_paid
this.tds_percentage = (this.tds/this.amount) * 100
},
感谢您的帮助并花时间帮助一个好奇但真正的 Vue 新手。
解决方案
推荐阅读
- tensorflow - 为什么在损失函数中使用均值而不是总和?
- python - 如何在 altair 中创建集群条形图
- python - 如何使 python 诅咒应用程序管道友好?
- twilio - 要使用 Twilio Sim 卡,是否需要越狱 TracFone?
- php - 从 apache 网站上传文件后出现 404,但可从文件管理器访问。文件夹和文件权限为 644
- javascript - Symfony 4:具有预览和附加/删除功能的多张图片上传
- android - 如何更新子集合 Firestore?
- java - 如何在 android 中获取 indexof(object) 请参阅我的示例以了解
- c# - 为服务器端 DOM 初始化 JQuery
- java - 使用 Java Hash map 转换 MorseCode 中的文本