taro icon indicating copy to clipboard operation
taro copied to clipboard

未找到 van-notify 节点,请确认 selector 及 context 是否正确

Open longhaoteng opened this issue 2 years ago • 5 comments

相关平台

微信小程序

小程序基础库: 2.24.3 使用框架: Vue 3

复现步骤

  1. ui组件库:vant-weapp
  2. 在A页面中使用 <van-notify id="test-notify-id" />(注:test-notify-id 为全局唯一id)
  3. 编译项目:NODE_ENV=production taro build --type weapp
  4. 进入A页面,查看渲染后的wxml image 此时触发Notify({ selector: '#test-notify-id', type: 'warning', message: 'test' })表现是正常的
  5. 退出A页面,再重新进入A页面(第二次进入A页面),查看渲染后的wxml image id被替换成了随机字符串,导致Notify()失败,报错未找到 van-notify 节点,请确认 selector 及 context 是否正确

ps:NODE_ENV=production taro build --type weapp编译才会有这种问题,taro build --type weapp编译时id不会被替换

期望结果

设置了id的元素id保持不变

实际结果

id被替换成了随机字符串

环境信息

👽 Taro v3.4.10


  Taro CLI 3.4.10 environment info:
    System:
      OS: Linux 4.4 Ubuntu 20.04.3 LTS (Focal Fossa)
      Shell: 5.8 - /usr/bin/zsh
    Binaries:
      Node: 16.13.0 - /usr/bin/node
      Yarn: 1.22.15 - /usr/bin/yarn
      npm: 8.3.1 - /usr/bin/npm
    npmPackages:
      @tarojs/components: 3.4.10 => 3.4.10
      @tarojs/mini-runner: 3.4.10 => 3.4.10
      @tarojs/runtime: 3.4.10 => 3.4.10
      @tarojs/taro: 3.4.10 => 3.4.10
      @tarojs/webpack-runner: 3.4.10 => 3.4.10
      babel-preset-taro: 3.4.10 => 3.4.10
      eslint-config-taro: 3.4.10 => 3.4.10

longhaoteng avatar May 25 '22 06:05 longhaoteng

@longhaoteng 麻烦提供一下 Demo

Chen-jj avatar May 25 '22 07:05 Chen-jj

@longhaoteng 麻烦提供一下 Demo

@Chen-jj 无法提供Demo,复现步骤写的很详细了

longhaoteng avatar May 25 '22 07:05 longhaoteng

怎么打上question标签了,这个问题属于bug吧 任意设置了id(全局唯一)的元素,在二次进入页面后,id都会变成随机id 例:<view id="test_id" /> 第一次进入页面 image 第二次进入页面 image NODE_ENV=production编译就能复现

longhaoteng avatar May 27 '22 10:05 longhaoteng

@Chen-jj

longhaoteng avatar Jun 06 '22 01:06 longhaoteng

我也遇到了,我也觉得这是一个严重BUG

geeklibin avatar Aug 30 '22 07:08 geeklibin