So, for some obscure reason, it works with
<example :rowsfromdatabase="{{ $rowsFromPHP }}"></example>
If any one can explain why the added quotes solve the problem, I'd be thrilled :).
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
Hi all,
I have a json object containing (see the whitepace after Accept_):
{[
"id" => 1
"text" => "Accept_ _TODO"
]}
I then give it to vue in a blade file:
<example :rowsfromdatabase={{ $rowsFromPHP }}></example>
And I get the error:
[Vue warn]: Error compiling template:
<div id="app">
<example :rowsfromdatabase="[{"id":1,"text":"Accept_" _todo"}]=""></example>
</div>
- invalid expression: :rowsfromdatabase="[{"id":1,"key":"claim_config_step_action_accept_claim","text":"Accept_"
(found in <Root>)
Blade (or someone :) ) sends "Accept_" rather than "Accept_ _TODO"}]. Anything I can do? I tried {{{ or {!! instead of {{ but it doesn't work.
@SwissNight This is how vue works. You need the double-quotes since you can also pass an expression as an argument. For example:
<example :some-key="3+4"></example>
In the above case, the value of someKey will be 7 and not the string 3+4.
Please or to participate in this conversation.