widgetImage.vue 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. <template>
  2. <div class="imagebox" :style="styleColor">
  3. <img
  4. :class="transStyle.startRotate ? 'startImg' : ''"
  5. :style="imgStyle"
  6. :src="imgStyle.imageAdress"
  7. alt=""
  8. />
  9. </div>
  10. </template>
  11. <script>
  12. export default {
  13. name: "WidgetImage",
  14. components: {},
  15. props: {
  16. value: Object,
  17. ispreview: Boolean
  18. },
  19. data() {
  20. return {
  21. options: {}
  22. };
  23. },
  24. computed: {
  25. transStyle() {
  26. return this.objToOne(this.options);
  27. },
  28. styleColor() {
  29. return {
  30. position: this.ispreview ? "absolute" : "static",
  31. background: this.transStyle.background,
  32. "text-align": this.transStyle.textAlign,
  33. width: this.transStyle.width + "px",
  34. height: this.transStyle.height + "px",
  35. left: this.transStyle.left + "px",
  36. top: this.transStyle.top + "px",
  37. right: this.transStyle.right + "px"
  38. };
  39. },
  40. imgStyle() {
  41. return {
  42. imageAdress: this.transStyle.imageAdress,
  43. "border-radius": this.transStyle.borderRadius + "px",
  44. opacity: this.transStyle.transparency / 100,
  45. animation: this.transStyle.startRotate? "turn "+(101-this.transStyle.rotationSpeed)/10+"s linear infinite":"none"
  46. };
  47. }
  48. },
  49. watch: {
  50. value: {
  51. handler(val) {
  52. this.options = val;
  53. },
  54. deep: true
  55. }
  56. },
  57. created() {
  58. this.options = this.value;
  59. },
  60. mounted() {},
  61. methods: {}
  62. };
  63. </script>
  64. <style scoped lang="scss">
  65. .imagebox {
  66. width: 100%;
  67. height: 100%;
  68. overflow: hidden;
  69. }
  70. .imagebox img {
  71. width: 100%;
  72. height: 100%;
  73. }
  74. .startImg {
  75. animation: turn 1s linear infinite;
  76. }
  77. </style>