Mini Program, how to make the outermost view of the component highly adaptive?

in Mini Program"s project, if you want to do a reusable view, to be implemented with components, the height in it should be specified when you use it.

related codes

/ / Please paste the code text below (do not replace the code with pictures)
component.wxml

<view class="container">
    <view class="v1" style="height:20%"> </view>
    <view class="v1" style="height:30%"> </view>
    <view class="v1" style="height:30%"> </view>
    <view class="v1" style="height:20%"> </view>
</view>

index.wxml

<view>
    <componentView style="height: 120rpx">
        
    </componentView>
</view>

what result do you expect? What is the error message actually seen?

the result is either a height of 0 or the proportion of sub-view does not come out.

solve?!

Nov.27,2021

  • component.wxml
  component document  

Menu