2

I'm trying to bind data to b-input inside a b-table however, changes to the input value will not propagate to the items of the table.

Here is my code so far:

    <template>
        <div :class="`col-${fields.length}`">
            <h6 class="text text-center">{{header}}</h6>
            <b-table
                :items="items"
                :fields="fields"
            >
                <template v-for="field in fields"
                    :slot="field.key" slot-scope="data">
                    <b-form-input class="border-0 no-shadow p-1" type="number" v-model="data.value"
                    ></b-form-input>
                </template>
            </b-table>
        </div>
    </template>

    <script>
    export default {
        props: [ "header", "fields", "items"]
    }
    </script>

Basically all I want, is to change the values of items everytime I change the corresponding value of a b-input. But itemswill never change...

What am I doing wrong here?

1 Answer 1

4

The solution is to use the items directly instead of using the data.value.

    <template v-for="field in fields"
      :slot="field.key" slot-scope="data">
        <b-form-input class="border-0 no-shadow p-1" type="number" v-model="data.item[field.key]"></b-form-input>
    </template>
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.