screen_rotation
Copied to Clipboard
<html> <head> <script src="https://cdn.jsdelivr.net/npm/vue/dist/vue.js"></script> </head> <body> <div id="app"> <h3>To obtain unique values from an array in Vue.js,</h3> <p>Array:{{items}}</p> <p>Get Unique Value</p> <ul> <li v-for="item in uniqueItems" :key="item">{{ item }}</li> </ul> </div> <script type="module"> const app = new Vue({ el: "#app", data() { return { newItem: '', items: ['a', 'b', 'c', 'c', 'd', 'd', 'e','f','f'], } }, computed: { uniqueItems() { return this.items.filter((item, index, self) => { return self.indexOf(item) === index; }); }, }, }); </script> </body> </html>