-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathclientRootMixin.js
35 lines (33 loc) · 1.14 KB
/
clientRootMixin.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import CodeCopy from './CodeCopy.vue'
import Vue from 'vue'
import './style.css'
export default {
updated() {
this.update()
},
methods: {
update() {
setTimeout(() => {
document.querySelectorAll(selector).forEach(el => {
if (el.classList.contains('code-copy-added')) return
let ComponentClass = Vue.extend(CodeCopy)
let instance = new ComponentClass()
let options = {
align: align,
color: color,
backgroundTransition: backgroundTransition,
backgroundColor: backgroundColor,
successText: successText,
staticIcon: staticIcon
}
instance.options = { ...options }
instance.code = el.innerText
instance.parent = el
instance.$mount()
el.classList.add('code-copy-added')
el.appendChild(instance.$el)
})
}, 100)
}
}
}