Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Taro Next 元素嵌套 16 层之后会出现 <comp is="comp"> #7349

Closed
Miaonster opened this issue Aug 16, 2020 · 4 comments
Closed

Taro Next 元素嵌套 16 层之后会出现 <comp is="comp"> #7349

Miaonster opened this issue Aug 16, 2020 · 4 comments
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x

Comments

@Miaonster
Copy link
Contributor

Miaonster commented Aug 16, 2020

相关平台

微信小程序

复现仓库

https://github.com/Miaonster/demo-taro-next-nest-view
小程序基础库: 2.12.1
使用框架: React

复现步骤

在我给出的 demo 中,src/page/index/index.jsx 中使用嵌套 16 层以上的 View 后,在微信开发者工具中,查看 dom 结构,会发现 <View> 出现 <comp is="comp"> 在之中

import React, { Component } from 'react'
import { View, Text } from '@tarojs/components'
import './index.css'

export default class Index extends Component {
  render () {
    return (
      <View className='index'>
        <Text>Hello world!</Text>
        <View>
          <View>
            <View>
              <View>
                <View>
                  <View>
                    <View>
                      <View>
                        <View>
                          <View>
                            <View>
                              <View>
                                <View>
                                  <View>
                                    <View>
                                      haha
                                    </View>
                                  </View>
                                </View>
                              </View>
                            </View>
                          </View>
                        </View>
                      </View>
                    </View>
                  </View>
                </View>
              </View>
            </View>
          </View>
        </View>
      </View>
    )
  }
}

期望结果

期望正常渲染成 view,而不是嵌套在 <comp is="comp">

实际结果

实际会嵌套一层 <comp is="comp">

环境信息

👽 Taro v3.0.7


  Taro CLI 3.0.7 environment info:
    System:
      OS: macOS 10.15.5
      Shell: 3.0.2 - /usr/local/bin/fish
    Binaries:
      Node: 14.3.0 - ~/.config/nvm/14.3.0/bin/node
      Yarn: 1.22.4 - /usr/local/bin/yarn
      npm: 6.14.5 - ~/.config/nvm/14.3.0/bin/npm
    npmPackages:
      @tarojs/components: 3.0.7 => 3.0.7 
      @tarojs/mini-runner: 3.0.7 => 3.0.7 
      @tarojs/react: 3.0.7 => 3.0.7 
      @tarojs/runtime: 3.0.7 => 3.0.7 
      @tarojs/taro: 3.0.7 => 3.0.7 
      @tarojs/webpack-runner: 3.0.7 => 3.0.7 
      babel-preset-taro: 3.0.7 => 3.0.7 
      eslint-config-taro: 3.0.7 => 3.0.7 
      react: ^16.10.0 => 16.13.1 

image

@taro-bot2 taro-bot2 bot added F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x labels Aug 16, 2020
@Chen-jj
Copy link
Contributor

Chen-jj commented Aug 17, 2020

故意的,借用自定义组件重新开始 template 递归

@Miaonster
Copy link
Contributor Author

@Chen-jj 多加一层元素可能会导致样式有问题,比如在最后一层使用 flex 布局,如果正好给子元素增加一个 <comp> ,flex 布局就无法正确使用,这种情况改怎么解决呢?

@Chen-jj
Copy link
Contributor

Chen-jj commented Aug 17, 2020

有一个配置项, mini.baselevel 好像是,可以配置默认层数,可以去文档配置详情找找。层数太多,包越大,小心使用

@Miaonster
Copy link
Contributor Author

好的,感谢 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
F-react Framework - React T-weapp Target - 编译到微信小程序 V-3 Version - 3.x
Projects
None yet
Development

No branches or pull requests

2 participants