[Vuejs]-Dynamically show serial numbers in vue component

0👍

You could create a counter that is available globally and increments with every use.

Here’s an example implementation:

Vue.prototype.$elNum = 0;
Vue.prototype.$getElNum = () => Vue.prototype.$elNum += 1;

then whenever you are creating an element anywhere in the app, you can set the key or serialNumber by setting it to this.$getElNum()

Leave a comment