fix bug
This commit is contained in:
@@ -0,0 +1,23 @@
|
||||
Vue.mixin({
|
||||
mounted() {
|
||||
if (this.$options.style) {
|
||||
const styleId = `style-${this._uid}`
|
||||
const style = document.createElement("style")
|
||||
style.id = styleId
|
||||
//支持函数和字符串
|
||||
const css = typeof this.$options.style === "function" ? this.$options.style.call(this) : this.$options.style
|
||||
style.textContent = css
|
||||
document.head.appendChild(style)
|
||||
}
|
||||
},
|
||||
|
||||
beforeDestroy() {
|
||||
if (this.$options.style) {
|
||||
const styleId = `style-${this._uid}`
|
||||
const style = document.getElementById(styleId)
|
||||
if (style) {
|
||||
document.head.removeChild(style)
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
Reference in New Issue
Block a user