我想显示数据库中的变量并在之前对其进行舍入。你能帮我了解一下语法吗?
<h2 class="txt-bold">Rating: {{roundHalf(ListOrg.rating)}}</h2>
computed: {
roundHalf: function(num) {
return Math.round(num * 2) / 2;
}
}
最佳答案
如果您想使用计算值:
<h2 class="txt-bold">Rating: {{roundHalf}}</h2>
computed: {
roundHalf: function() {
return Math.round(this.ListOrg.rating * 2) / 2;
}
}
关于javascript - 如何在vue模板+laravel中使用计算函数显示变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55368762/