Answer the question
In order to leave comments, you need to log in
How to bind to a dynamic property from another component?
There is a vuetifyjs table component in which I display my component number-input
Table:
<v-data-table
:items="items"
>
<template slot="items" scope="props">
<td>{{ props.item.name }}</td>
<td class="text-xs-right">{{ props.item.price }} р.</td>
<td class="text-xs-right">
<number-input
:val="props.item.count"
:min="1"
:max="props.item.stock"
/>
</td>
<td class="text-xs-right">{{ props.item.stock }} {{ props.item.unit }} </td>
<td class="text-xs-center"><remove-btn :id='props.item.id' /></td>
</template>
</v-data-table>
<template>
<div class="input-number_wrapper">
<span class="input-number-decrement" @click="decrement()">–</span>
<input class="input-number" type="text" v-model="val" min="min" max="max">
<span class="input-number-increment" @click="increment()">+</span>
</div>
</template>
export default {
data () {
return {
}
},
props: ['val','min','max'],
methods: {
decrement () {
if ((this.val - 1) < this.min) {
return;
}
this.val -= 1
},
increment () {
if ((this.val + 1) > this.max) {
return;
}
this.val += 1
}
}
}
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question