vue中将元素加入body中
// 将弹框加入Body中addRemoveDateWinToBody(type) {this.$nextTick(() => {const body = document.querySelector('body')if (type) {// 显示let zDateWin = this.$refs.zDateWinlet pTabName = zDateWin.paren...
·
// 将弹框加入Body中
addRemoveDateWinToBody(type) {
this.$nextTick(() => {
const body = document.querySelector('body')
if (type) {
// 显示
let zDateWin = this.$refs.zDateWin
let pTabName = zDateWin.parentNode ? zDateWin.parentNode.tagName : ''
if (pTabName != 'body') {
// 未加入,body,选择加入
if (body.append) {
body.append(zDateWin)
} else {
body.appendChild(zDateWin)
}
}
} else {
// 隐藏
body.removeChild(body.lastChild)
}
})
},
更多推荐
已为社区贡献7条内容
所有评论(0)