demo: fix compile error

This commit is contained in:
pengfei.zhou 2023-04-04 20:41:34 +08:00 committed by osborn
parent 91d5d016f9
commit d80507a70f

View File

@ -9,6 +9,7 @@ import {
SlideItem, SlideItem,
Image, Image,
Color, Color,
createRef,
} from "doric"; } from "doric";
const imageUrls = [ const imageUrls = [
"http://b.hiphotos.baidu.com/image/pic/item/908fa0ec08fa513db777cf78376d55fbb3fbd9b3.jpg", "http://b.hiphotos.baidu.com/image/pic/item/908fa0ec08fa513db777cf78376d55fbb3fbd9b3.jpg",
@ -33,18 +34,19 @@ export class SliderInListDemo extends Panel {
parent={root} parent={root}
layoutConfig={layoutConfig().most()} layoutConfig={layoutConfig().most()}
itemCount={50} itemCount={50}
renderItem={() => renderItem={() => {
( const sliderRef = createRef<Slider>();
return (
<ListItem layoutConfig={layoutConfig().mostWidth().fitHeight()}> <ListItem layoutConfig={layoutConfig().mostWidth().fitHeight()}>
<Slider <Slider
ref={sliderRef}
layoutConfig={layoutConfig() layoutConfig={layoutConfig()
.mostWidth() .mostWidth()
.fitHeight() .fitHeight()
.configMinHeight(1)} .configMinHeight(1)}
itemCount={imageUrls.length} itemCount={imageUrls.length}
onPageSlided={function (idx) { onPageSlided={(idx) => {
const sliderView = this as unknown as Slider; sliderRef.current.slidePosition = idx;
sliderView.slidePosition = idx;
}} }}
renderPage={(idx) => renderPage={(idx) =>
( (
@ -61,8 +63,8 @@ export class SliderInListDemo extends Panel {
} }
/> />
</ListItem> </ListItem>
) as ListItem ) as ListItem;
} }}
/>; />;
} }
} }