Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I pass prop to value of input with vue.js 2?

My vue component is like this :

<template>
    <div class="modal" tabindex="-1" role="dialog">
         <form method="post" :action="baseUrl+'/product/edit'">
            ...
            <input type="hidden" name="product_id" value="{{productId}}">
            ...
         </form>
    </div>
</template>

<script>
    export default {
        props:['productId'],
        ...
    }
</script>

There exist error like this :

value="{{productId}}": Interpolation inside attributes has been removed.

How can I solve this problem?

like image 329
moses toh Avatar asked Oct 16 '25 14:10

moses toh


1 Answers

Use the binding syntax.

<input type="hidden" name="product_id" v-bind:value="productId">

Or

<input type="hidden" name="product_id" :value="productId">
like image 171
Bert Avatar answered Oct 18 '25 10:10

Bert



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!