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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
| <template>
| <div>
| <viewer :images="images">
| <img
| v-for="(src,index) in images"
| :key="index"
| class="v-img"
| :src="src.url"
| :alt="src.name"
| :style="imgStyle"
| :onerror="defaultImg"
| >
| </viewer>
| </div>
| </template>
|
| <script>
| import { getFtpUrl } from '@/utils/base'
| import { str2Array } from '@/utils/tools'
| export default {
| props: {
| imgs: {
| type: [Array, String],
| default: function() {
| return []
| }
| },
| imgStyle: {
| type: String,
| default: 'width:100px; height:100px;'
| }
| },
| data() {
| return {
| defaultImg: 'this.src="' + require('../../../assets/404_images/404.png') + '"',
| images: []
| }
| },
| watch: {
| imgs(val) {
| if (typeof val === 'string') {
| this.images = str2Array(val)
| } else {
| this.images = val
| }
| }
| },
| created() {
| if (typeof this.imgs === 'string') {
| this.images = str2Array(this.imgs)
| } else {
| this.images = this.imgs
| }
| },
| mounted() {
| this.images.forEach(obj => {
| if (obj.path != undefined && obj.path.length > 0) {
| obj.url = this.getUrl(obj.path)
| }
| })
| },
| methods: {
| getUrl(path) {
| return getFtpUrl() + path
| }
| }
| }
| </script>
|
| <style scoped>
| /* 图片预览层级*/
| .viewer-container {
| z-index: 90709102!important;
| }
| </style>
|
|