废话不多说,直接上代码
import { ScrollView } from "@tarojs/components";
import Taro, { useReady } from "@tarojs/taro";
const [scrollHeight, setScrollHeight] = useState('84vh');
useReady(() => {
// 设置ScrollView的动态高度
Taro.nextTick(() => {
Taro.getSystemInfo({
success: (res) => {
const query = wx.createSelectorQuery();
query.select("#scrollview").boundingClientRect();
query.exec((resData) => {
console.log('resres', res)
console.log('resData', resData)
if (resData && resData.length) {
setScrollHeight(res.screenHeight - resData[0].top + "px")
}
});
},
});
});
});
<ScrollView
style={{ height: scrollHeight }}
id="scrollview"
scrollY
scrollWithAnimation
>
</ScrollView>
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。