index.vue 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. <template>
  2. <view class="section-name" :class="'class' + elIndex">
  3. {{title}}
  4. </view>
  5. </template>
  6. <script>
  7. import guid from '@/utils/guid.js';
  8. import {rpxTopx} from '@/utils/tool.js'
  9. export default {
  10. props: {
  11. title: {
  12. type: String,
  13. default:''
  14. },
  15. value: {
  16. type: String,
  17. default:''
  18. },
  19. },
  20. data() {
  21. return {
  22. elIndex: guid(),
  23. }
  24. },
  25. watch: {
  26. src(val,old) {
  27. if(val != old){
  28. this.isError = false
  29. this.url1 = val
  30. }
  31. }
  32. },
  33. methods: {
  34. error() {
  35. this.isError = true
  36. }
  37. },
  38. onReady() {
  39. this.Observer = uni.createIntersectionObserver(this)
  40. this.Observer.relativeToViewport({bottom: 200}).observe('.class' + this.elIndex, (res) => {
  41. this.$emit('changeTag',this.value)
  42. })
  43. // this.Observer = uni.createIntersectionObserver(this)
  44. // this.Observer.relativeTo('.test',{bottom: 0}).observe('.class' + this.elIndex, (res) => {
  45. // console.log(12312);
  46. // this.$emit('changeTag',this.value)
  47. // })
  48. // this.Observer = uni.createIntersectionObserver(this)
  49. // this.Observer.relativeTo('.test',{top: 0}).observe('.class' + this.elIndex, (res) => {
  50. // this.$emit('changeTag',this.value)
  51. // })
  52. },
  53. beforeDestroy() {
  54. this.Observer&&this.Observer.disconnect()
  55. }
  56. }
  57. </script>
  58. <style lang="scss" scoped>
  59. .zs-img-box{
  60. position: relative;
  61. .image{
  62. vertical-align: bottom;
  63. will-change: transform
  64. }
  65. }
  66. </style>