Web Components là gì?
Web Components là gì?
Web Components là bộ chuẩn web cho phép tạo phần tử HTML tuỳ chỉnh, tái sử dụng, đóng gói (encapsulated) mà không cần framework.
<template> và <slot> để chứa cấu trúc tái sử dụng và chèn nội dung.<user-card name="An"></user-card>
<script>
class UserCard extends HTMLElement {
static observedAttributes = ['name'];
constructor() {
super();
this.attachShadow({ mode: 'open' }).innerHTML = `
<style>.card{border:1px solid #ddd;padding:8px;border-radius:6px}</style>
Đăng nhập để tham gia thảo luận cùng mọi người.
Chưa có bình luận nào
Hãy là người đầu tiên chia sẻ suy nghĩ của bạn.