This commit is contained in:
X1627315083@163.com
2026-03-19 14:55:25 +08:00
parent 6aadead374
commit 8571c94336
3 changed files with 48 additions and 6 deletions

View File

@@ -30,6 +30,20 @@ app.use(router)
.use(i18n)
.mount('#app')
// 简写形式
const vLoadimg = (el, binding) => {
const src = binding.value
if (el.src === src) return
const img = new Image()
img.src = src
img.onload = () => {
el.src = src
}
img.onerror = () => {
console.log('图片加载失败:', src)
}
}
// 注册
app.directive('loadimg', vLoadimg)
flexible();