fix: 修复nodata提示错误

This commit is contained in:
chenjinsong
2022-01-06 17:32:20 +08:00
parent f4ca2fa44c
commit f0acc006e7

View File

@@ -358,16 +358,24 @@ export const noData = {
if (el) { if (el) {
if (binding.value) { if (binding.value) {
setTimeout(() => { setTimeout(() => {
// 是否已有no data
let alreadyHasNoData = false
el.childNodes.forEach(node => { el.childNodes.forEach(node => {
if (node.classList && node.classList.value.indexOf('no-data') > -1) {
alreadyHasNoData = true
} else {
node.style && (node.style.display = 'none') node.style && (node.style.display = 'none')
}
}) })
if (!alreadyHasNoData) {
el.insertBefore(noDataDomFactory(), el.childNodes[0]) el.insertBefore(noDataDomFactory(), el.childNodes[0])
}
}) })
} else { } else {
setTimeout(() => { setTimeout(() => {
for (let i = 0; i < el.childNodes.length; i++) { for (let i = 0; i < el.childNodes.length; i++) {
const node = el.childNodes[i] const node = el.childNodes[i]
if (node.innerText === 'No data') { if (node.classList && node.classList.value.indexOf('no-data') > -1) {
el.removeChild(node) el.removeChild(node)
break break
} }