timmy / Streamlit 整合 Lit Web Component
0 gustos
0 bifurcaciones
1 archivos
Última actividad 10 months ago
此範例展示如何在 Streamlit 應用中嵌入 Lit Web Component,而不依賴 CDN。使用 Web Components 技術,可封裝自訂 UI 元件,並透過 JavaScript 互動,適用於建立模組化的前端元件,提升 Web 應用的可維護性與重用性。
| 1 | import streamlit as st |
| 2 | import streamlit.components.v1 as components |
| 3 | |
| 4 | st.title("使用 Lit Web Component (無 CDN)") |
| 5 | |
| 6 | lit_component = """ |
| 7 | <script type="module"> |
| 8 | class MyLitComponent extends HTMLElement { |
| 9 | constructor() { |
| 10 | super(); |
Siguiente
Anterior