We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 803eded commit bb122beCopy full SHA for bb122be
src/mixins/safeId.js
@@ -1,13 +1,15 @@
1
export default{
2
- id: {
3
- type: String,
4
- default: null
5
- },
6
computed: {
7
safeId () {
8
- if(this.id)
9
- return this.id
10
- return Math.random().toString(36).replace('0.', '') + (new Date()).getTime().toString(36)
+ if(this.id || this.$attrs.id)
+ return this.id || this.$attrs.id
+ return generateSafeId()
11
}
12
13
+
+function generateSafeId () {
+ const key = Math.random().toString(36).replace('0.', '') +
+ (new Date()).getTime().toString(36)
14
+ return '__safe_id__' + key
15
+}
0 commit comments