refreshComponent.js 633 B

12345678910111213141516171819202122232425262728293031
  1. const refreshComponentMixin = {
  2. data () {
  3. return {
  4. updateKey: 0
  5. }
  6. },
  7. computed: {
  8. Data () {
  9. return JSON.parse(JSON.stringify(this.config))
  10. }
  11. },
  12. watch: {
  13. Data: {
  14. handler (newVal, oldVal) {
  15. this.$nextTick(() => {
  16. if ((newVal.w !== oldVal.w) || (newVal.h !== oldVal.h)) {
  17. this.updateKey = new Date().getTime()
  18. }
  19. })
  20. },
  21. deep: true
  22. }
  23. },
  24. methods: {
  25. // 由于静态组件没有混入公共函数,所以需要定义一个changeStyle方法,以免报错
  26. changeStyle () {
  27. }
  28. }
  29. }
  30. export { refreshComponentMixin }