T***@Outlook.com
T***@Outlook.com
  • 发布:2024-11-04 15:07
  • 更新:2024-11-04 15:07
  • 阅读:66

【报Bug】createIntersectionObserver函数与page-meta冲突。

分类:uni-app

产品分类: uniapp/H5

PC开发环境操作系统: Windows

PC开发环境操作系统版本号: 23H2(22631.4317)

HBuilderX类型: Alpha

HBuilderX版本号: 4.32

浏览器平台: Edge

浏览器版本: 130.0.2849.68

项目创建方式: HBuilderX

示例代码:

import { onMounted , getCurrentInstance} from 'vue'

const instanceContext = getCurrentInstance()
onMounted(() => {
uni.createIntersectionObserver().relativeTo('.app', {}).observe(".target", (res) => {
console.log('call')
});
})
<template>
<page-meta></page-meta>
<view class="app">
<view class="target"></view>
</view>
</template>

操作步骤:

按照上述中的代码示例即可复现,用的是vue3

预期结果:

既可以使用page-meta也可以使用, uni.createIntersectionObserver()

实际结果:

import { onMounted , getCurrentInstance} from 'vue'

const instanceContext = getCurrentInstance()
onMounted(() => {
uni.createIntersectionObserver().relativeTo('.app', {}).observe(".target", (res) => {
console.log('call')
});
})
<template>
<page-meta></page-meta>
<view class="app">
<view class="target"></view>
</view>
</template>

bug描述:

page-meta标签必须是一个元素,并且不能存在嵌套元素。那么我的<view class="app"></view>只能写在page-meta的下面。此次使用uni.createIntersectionObserver(),控制台就会抛出错误:Uncaught TypeError: $el.querySelector is not a function。经过逆向发现,const $el = findElem(component);查到的元素是page-meta。

2024-11-04 15:07 负责人:无 分享
已邀请:

要回复问题请先登录注册