본문 바로가기
REFLEX 튜토리얼

rx에서 유튜브 allowFullScreen 활성화하는 방법

by 일코 2023. 10. 9.

아래 방법은 전체화면 아이콘이 활성화되지 않는다. (잘못된 방법)

import reflex as rx


class State(rx.State):
    pass


def index() -> rx.Component:
    return rx.box(
        element="iframe",
        src="https://www.youtube.com/embed/9bZkp7q19f0",
        allowFullScreen=True)  # <-- 여기가 잘못되었음

app = rx.App()
app.add_page(index)
app.compile()

대신 아래 방법으로는 전체화면이 잘 실행된다.

import reflex as rx


class State(rx.State):
    pass


def index() -> rx.Component:
    return rx.box(
        element="iframe",
        src="https://www.youtube.com/embed/9bZkp7q19f0",
        custom_attrs=dict(allowFullScreen=True))  # <-- 이렇게 넣어야 함.

app = rx.App()
app.add_page(index)
app.compile()

rx.html을 쓰는 방식보다는 훨씬 간편함.

참고로 아래처럼 rx.html 안에 iframe을 삽입해도 잘 적용됨.

rx.html("""<iframe src="https://www.youtube.com/embed/9bZkp7q19f0" width="100%" height="500" frameborder="0" allowfullscreen></iframe>""")

댓글