NervJS / taro

开放式跨端跨框架解决方案,支持使用 React/Vue/Nerv 等框架来开发微信/京东/百度/支付宝/字节跳动/ QQ 小程序/H5/React Native 等应用。 https://taro.zone/
https://docs.taro.zone/
Other
35.34k stars 4.77k forks source link

taro vue3 v3.6.2 使用 taro build native-components 编译过去后会报 Maximum call stack size exceeded #13566

Closed Jackie-5 closed 1 year ago

Jackie-5 commented 1 year ago

相关平台

微信小程序

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

复现步骤

重现链接 https://github.com/Jackie-5/taro-vue3-to-mini

使用 NODE_ENV=production taro build native-components --type weapp 编译后

vue3的写法改为

到原生小程序就会看到报错,如果把 NODE_ENV 改为 development 就不会报错

我这边直接使用的是官方的 demo https://github.com/NervJS/taro/tree/next/examples/blended-taro-component-vue3

可以把任意的.vue文件的 改为上述描写就会报错

https://github.com/Jackie-5/taro-vue3-to-mini 这里已经提供两种写法

image

期望结果

不要报错并成功编译

实际结果

转过去后 用原生小程序打开就会报 Maximum call stack size exceeded

环境信息

Taro CLI 3.6.2 environment info:
    System:
      OS: macOS 11.7.4
      Shell: 5.8 - /bin/zsh
    Binaries:
      Node: 19.8.1 - ~/.nvm/versions/node/v19.8.1/bin/node
      Yarn: 1.22.19 - ~/.nvm/versions/node/v19.8.1/bin/yarn
      npm: 9.5.1 - ~/.nvm/versions/node/v19.8.1/bin/npm
    npmPackages:
      @tarojs/cli: 3.6.2 => 3.6.2 
      @tarojs/components: 3.6.2 => 3.6.2 
      @tarojs/helper: 3.6.2 => 3.6.2 
      @tarojs/plugin-framework-vue3: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-alipay: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-h5: ^3.6.2 => 3.6.2 
      @tarojs/plugin-platform-jd: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-qq: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-swan: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-tt: 3.6.2 => 3.6.2 
      @tarojs/plugin-platform-weapp: 3.6.2 => 3.6.2 
      @tarojs/router: 3.6.2 => 3.6.2 
      @tarojs/runtime: 3.6.2 => 3.6.2 
      @tarojs/shared: 3.6.2 => 3.6.2 
      @tarojs/taro: 3.6.2 => 3.6.2 
      @tarojs/taro-h5: 3.6.2 => 3.6.2 
      @tarojs/taro-loader: 3.6.2 => 3.6.2 
      @tarojs/webpack5-runner: 3.6.2 => 3.6.2 
      babel-preset-taro: 3.6.2 => 3.6.2 
      eslint-config-taro: 3.6.2 => 3.6.2 
jxxbd91 commented 1 year ago

需要声明一下 _scope 这个props,如果不声明的话,在小程序 taro runtime 下,setData 的时候会有一个 自引用的对象,会导致小程序模板渲染时爆栈

defineComponent({
    props: {
        _scope: {
           type: Object
        }
    }
})
Jackie-5 commented 1 year ago

需要声明一下 _scope 这个props,如果不声明的话,在小程序 taro runtime 下,setData 的时候会有一个 自引用的对象,会导致小程序模板渲染时爆栈

defineComponent({
    props: {
        _scope: {
           type: Object
        }
    }
})

感谢 已经可以了

Chen-jj commented 1 year ago

可以帮忙提交下 PR 修改 Taro example 哈~

HaolinHom commented 1 year ago

需要声明一下 _scope 这个props,如果不声明的话,在小程序 taro runtime 下,setData 的时候会有一个 自引用的对象,会导致小程序模板渲染时爆栈

defineComponent({
    props: {
        _scope: {
           type: Object
        }
    }
})

@jxxbd91 taro build native-components --type weapp --watch 构建出来是正常的。但是taro build native-components --type weapp构建出来的就会堆栈溢出,需要 props 加上 _scope 才正常。