javascript - array.push 添加整数作为字符串
问题描述
嗨,我将 laravel 与 vuejs 和 javascript 代码一起使用,这是我的 vuejs 代码
for(i = 0;i<response['data'].length;i++)
{
this.edited_lines.push(
{
id:response['data'][i]['id'], // this is integer
cost_center_id:response['data'][i]['cost_center_id'], // this is integer
credit:response['data'][i]['note'], // this is string
}
);
}
直到现在一切都很好..但是在我的刀片中我做了这个代码
<tr v-for='line , id in edited_lines'>
<td>
@php $cost_center_id = "{{line['cost_center_id']}}"; @endphp
{{gettype($cost_center_id)}} // this always resturn string not integer
</td>
</tr>
并且因为如果我在刀片中执行此操作,它总是返回字符串而不是整数,我会报错
{{$cost_center_id * 1}} // if i put this code in my blade i gat error below
A non-numeric value encountered
我试着这样做..
cost_center_id:1,
并在这里得到同样的错误任何帮助谢谢..
解决方案
推荐阅读
- node.js - 如何在预定义时间后切断 aws sdk s3 的连接?
- sas - 我更改了列名,但 SAS PROC REPORT 仍使用旧名称
- powershell - powershell版本号比较
- sql - 如何在rails中的同一张表上获得具有不同where条件的列的总和?
- c# - 在MVC中的javascript中嵌套foreach
- ruby-on-rails - Rails - 检查查询是否没有返回结果
- java - Wildfly:服务器重启后授权失败
- powershell - 如何在 PowerShell 中将 UInt32 转换为(负)Int32?
- java - Apache flink 无法编译加入流代码 | Kinesis 数据分析
- typescript - 如何在 iModelJS 中获取元素的坐标