Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bb122be

Browse filesBrowse files
committed
feat: add generateSafeId funtion.
1 parent 803eded commit bb122be
Copy full SHA for bb122be

File tree

Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+9
-7
lines changed

‎src/mixins/safeId.js

Copy file name to clipboard
+9-7Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,15 @@
11
export default{
2-
id: {
3-
type: String,
4-
default: null
5-
},
62
computed: {
73
safeId () {
8-
if(this.id)
9-
return this.id
10-
return Math.random().toString(36).replace('0.', '') + (new Date()).getTime().toString(36)
4+
if(this.id || this.$attrs.id)
5+
return this.id || this.$attrs.id
6+
return generateSafeId()
117
}
128
}
139
}
10+
11+
function generateSafeId () {
12+
const key = Math.random().toString(36).replace('0.', '') +
13+
(new Date()).getTime().toString(36)
14+
return '__safe_id__' + key
15+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.