Vuejs set operation on key failed: target is read-only
P粉785905797
P粉785905797 2023-08-26 11:26:25
0
1
552
<p>I use Laravel9 and Vuejs3. I have a blade view that passes a php variable to a vue component: </p> <pre class="brush:php;toolbar:false;"><subscription-form location="{{ $props['location'] }}" orientation="{{ $props['orientation'] }}" /></pre> <p>In the main vue where I receive the data, I have the following code in the script settings: </p> <pre class="brush:php;toolbar:false;">const initProps = defineProps(['location', 'orientation']); const values ​​= reactive(initProps);</pre> <p>This parent vue calls a component like this: </p> <pre class="brush:php;toolbar:false;"><component v-bind:is="steps[step]" v-bind:formValues="values" ></component></pre> <p>The problem is that my reactive variable <code>values</code> cannot be written in my child vue. I got an error</p> <pre class="brush:php;toolbar:false;">[Vue warn] Set operation on key "location" failed: target is readonly.</pre> <p>This happens when I do: </p> <pre class="brush:php;toolbar:false;">props.formValues.location = location;</pre> <p>It works when I don't have to pass php variables from blade to parent vue. But now I have two levels of data props, from the blade to the main vue and then from the main vue to the subcomponent and it's read only. </p> <p>Help! </p> <p>I tried switching the <code>initProps</code> or <code>values</code> variables from const type to var but it didn't do anything. </p>
P粉785905797
P粉785905797

reply all(1)
P粉481815897

I am disappointed... This doesn't work because my DefineProps() returns undefined The problem is: capital letters! I changed arrive My DefineProps() returns my object! Why doesn't this work with uppercase letters?

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!