1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
| <template>
| <img class="a111" @error="onError" :src="url" alt="" />
| </template>
|
| <script>
| export default {
| props: {
| src: {},
| },
| computed: {
| url() {
| if (
| this.src &&
| this.src.indexOf("http://apps.smartai.com/httpImage/") === -1 &&
| this.src.indexOf("/images") !== 0 &&
| this.src.indexOf("/files") !== 0
| ) {
| return "/httpImage/" + this.src;
| } else {
| return this.src;
| }
| },
| },
| data() {
| return {
| errorNum: 0,
| };
| },
| methods: {
| onError(err) {
| console.log(err);
| if (this.errorNum > 5) {
| return;
| }
| err.target.src = this.url + "?" + Math.random();
| this.errorNum++;
| },
| },
| };
| </script>
|
| <style>
| </style>
|
|