pic.vue 934 B

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. <template>
  2. <div id="pic">
  3. <el-tooltip content="点击放大" placement="right">
  4. <el-image :src="src" :style="styles" :fit="fit" :preview-src-list="list"></el-image>
  5. </el-tooltip>
  6. </div>
  7. </template>
  8. <script>
  9. import _ from 'lodash';
  10. export default {
  11. name: 'pic',
  12. props: {
  13. src: { type: String, required: true },
  14. styles: {
  15. type: Object,
  16. default: () => {
  17. return { width: `150px`, height: `150px` };
  18. },
  19. },
  20. fit: { type: String, default: 'scale-down' },
  21. },
  22. components: {},
  23. data: () => ({
  24. list: [],
  25. }),
  26. created() {},
  27. computed: {},
  28. methods: {},
  29. watch: {
  30. src: {
  31. immediate: true,
  32. deep: true,
  33. handler(val) {
  34. if (val) {
  35. if (_.isArray(val)) {
  36. this.$set(this, `list`, val);
  37. } else if (_.isString(val)) this.list.push(val);
  38. }
  39. },
  40. },
  41. },
  42. };
  43. </script>
  44. <style lang="less" scoped></style>