taro 编译自定义组件修改了组件名称

kulphzqa  于 4个月前  发布在  其他
关注(0)|答案(1)|浏览(97)

相关平台

微信小程序

小程序基础库: 3.1.1
使用框架: React

复现步骤

console.log(props.children)

const children = Array.isArray(props.children)
? props.children
: [props.children]

const slot = children.reduce((slot1, item) => {
const data = slot1
if (item && item.type && item.type.name) {
data[item.type.name] = item
}
return data
}, {})

console.log(slot)

yarn build:weapp 后 自定义组件名称 item.type.name 被修改成了随机字符串
yarn dev:weapp 正常

导致 {slot.Body} 失败

期望结果

build:weapp 不要修改自定义组件名称

实际结果

dev:weapp 正常 build:weapp 被修改

环境信息

👽 Taro v3.6.17

  Taro CLI 3.6.17 environment info:
    System:
      OS: macOS 13.5.2
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 18.17.1 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 9.6.7 - /usr/local/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.17 => 3.6.17 
      @tarojs/components: 3.6.17 => 3.6.17 
      @tarojs/helper: 3.6.17 => 3.6.17 
      @tarojs/mini-runner: 3.6.17 => 3.6.17 
      @tarojs/plugin-framework-react: 3.6.17 => 3.6.17 
      @tarojs/plugin-html: ^3.6.17 => 3.6.17 
      @tarojs/plugin-platform-alipay: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-h5: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-jd: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-qq: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-swan: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-tt: 3.6.17 => 3.6.17 
      @tarojs/plugin-platform-weapp: 3.6.17 => 3.6.17 
      @tarojs/react: 3.6.17 => 3.6.17 
      @tarojs/runtime: 3.6.17 => 3.6.17 
      @tarojs/shared: 3.6.17 => 3.6.17 
      @tarojs/taro: 3.6.17 => 3.6.17 
      @tarojs/webpack-runner: 3.6.17 => 3.6.17 
      babel-preset-taro: 3.6.17 => 3.6.17 
      eslint-config-taro: 3.6.17 => 3.6.17 
      react: ^18.0.0 => 18.2.0
esyap4oy

esyap4oy1#

@chrysanthemum 麻烦提供一下可复现的 demo

相关问题