-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
100 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<markdown> | ||
# The custom loading failed. Procedure | ||
|
||
In most cases, can use 'fallback-src' to set the image when it fails. | ||
</markdown> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from 'vue' | ||
import { ImageOutline as ImageOutlineIcon } from '@vicons/ionicons5' | ||
export default defineComponent({ | ||
components: { | ||
ImageOutlineIcon | ||
}, | ||
setup() { | ||
const url = ref('blablabla') | ||
const refresh = () => { | ||
url.value = 'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg' | ||
} | ||
const reloadError = () => { | ||
url.value = 'blablabla' | ||
} | ||
return { | ||
url, | ||
refresh, | ||
reloadError | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<n-flex vertical inline> | ||
<n-flex> | ||
<n-button type="error" @click="reloadError"> | ||
Load Fail | ||
</n-button> | ||
<n-button type="primary" @click="refresh"> | ||
Refresh | ||
</n-button> | ||
</n-flex> | ||
<n-image width="100" :src="url"> | ||
<template #error> | ||
<n-icon :size="100" color="lightGrey"> | ||
<ImageOutlineIcon /> | ||
</n-icon> | ||
</template> | ||
</n-image> | ||
</n-flex> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
<markdown> | ||
# 自定义加载失败 | ||
|
||
多数情况下可以使用 `fallback-src` 设定失败时的图像。 | ||
</markdown> | ||
|
||
<script lang="ts"> | ||
import { defineComponent, ref } from 'vue' | ||
import { ImageOutline as ImageOutlineIcon } from '@vicons/ionicons5' | ||
export default defineComponent({ | ||
components: { | ||
ImageOutlineIcon | ||
}, | ||
setup() { | ||
const url = ref('人生嘛,失败总是难免的') | ||
const refresh = () => { | ||
url.value = 'https://07akioni.oss-cn-beijing.aliyuncs.com/07akioni.jpeg' | ||
} | ||
const reloadError = () => { | ||
url.value = '人生嘛,失败总是难免的' | ||
} | ||
return { | ||
url, | ||
refresh, | ||
reloadError | ||
} | ||
} | ||
}) | ||
</script> | ||
|
||
<template> | ||
<n-flex vertical inline> | ||
<n-flex> | ||
<n-button type="error" @click="reloadError"> | ||
加载失败 | ||
</n-button> | ||
<n-button type="primary" @click="refresh"> | ||
刷新 | ||
</n-button> | ||
</n-flex> | ||
<n-image width="100" :src="url"> | ||
<template #error> | ||
<n-icon :size="100" color="lightGrey"> | ||
<ImageOutlineIcon /> | ||
</n-icon> | ||
</template> | ||
</n-image> | ||
</n-flex> | ||
</template> |