Vue Props data number round

Viewed 96

My raw data using uuid which is uuid_short() from database. When i put the data to vue props the number will round up / down. what should i do?

example:

test.blade.php:

<div class="content-wrapper">
    <div class="content">
        <div class="container-fluid">
            @include('cms.layouts.header', ['module' => 'TEST', 'mode' => 'List'])
            <test-list :test="{{$test}}"></test-list>
        </div>
    </div>
</div>

Raw data:

[{"id":15872,"test_uuid":27091219637075989}]

but in vue,m it shows: test_uuid : 27091219637075988. Why?

1 Answers

The highest value of Integer without losing its precision in JavaScript is

Number.MAX_SAFE_INTEGER, As your uuid value exceeds the safe limit, there will be precision errors.

an alternate option would be using it as a string or convert it into a BigInt()

Related