Vue.Js Array Slice
This method selects the elements from an array and returns the array of selected elements. Here in this tutorial, we are going to explain how to use slice method in VueJs. You can use our online editor to edit and run the demo online.
Vue.Js Array Slice Method Example Example
Here is an example of JavaScript slice function in VueJs-
Example:
<div id="app"> <p>item 1 = {{ item1 }}</p> <p>Result = {{result}}</p> <button @click="myFunction()">Click Me</button> </div> <script> new Vue({ el: '#app', data: { item1:[12, 10, 9, 5, 6, 4], result:'' }, methods:{ myFunction: function () { this.result = this.item1.slice(1, 3); } } }); </script> |
Output of above example-
Advertisements