I'm currently working on a client's range filtering feature using Vue.js. The filter involves an input
element with the type range
to adjust the total number of clients displayed. I have successfully linked the value of the input
to the **clients
** array. However, there seems to be an issue where the display does not update when increasing the range value.
Here is the template code:
<div id="app">
<input @input="filteredClients" type="range" min="0" max="10" v-model="clientTotal" />
<ul>
<li v-for="(client, index) in clients" :key="index">{{ client }}</li>
</ul>
</div>
This is the JavaScript code:
const app = new Vue({
el: "#app",
data: {
clientTotal: 10,
clients: [
'John Snow',
'Cullen Bohannon',
'Jamie Lannister',
'Jane Doe',
'Jamie Fraser',
'John Dow',
'Claire Fraser',
'Frank Underwood',
'Tony Stark',
'Client Eastwood'
],
},
mounted() {
this.filteredClients()
},
computed: {
filteredClients() {
this.clients.length = this.clientTotal
}
}
})
If you'd like to see the full code sample, you can do so by clicking here.