Each component has a unique id which can be accessed as this._uid. If you want more control over the ids you can for example, generate them inside a parent component.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | <template> <div> <label :for="id">Label text for {{id}}</label> <input :id="id" type="text" /> </div> </template> <script> export default { data () { return { id: null } }, mounted () { this.id = this._uid } } </script> |
If you like this question & answer and want to contribute, then write your question & answer and email to freewebmentor[@]gmail.com. Your question and answer will appear on FreeWebMentor.com and help other developers.