import { ref , renderSlot , onUnmounted , defineComponent } from 'vue' ; export const RenderComponent = defineComponent ( { props : { title : String } , setup ( ) { const count = ref < number > ( 1 ) ; const timer = setInterval ( ( ) => { count . value ++ ; } , 2000 ) ; onUnmounted ( ( ) => { clearInterval ( timer ) ; } ) ; return { count } ; } , render ( ) { const { count , $slots , title } = this ; return ( < div class = "render-component" > { renderSlot ( $slots , 'prefix' ) } { count } < br /> 这是props ： { title } < br /> { renderSlot ( $slots , 'default' ) } < /div>); } } ) ;