GetNotes Tools
stenciljs/core
Tool นี้คืออะไร
Stencil เป็นคอมไพเลอร์สำหรับสร้าง Web Components มาตรฐานโดยใช้ TypeScript และ JSX เหมาะสำหรับนักพัฒนาที่ต้องการสร้างคอมโพเนนต์ที่นำกลับมาใช้ใหม่ได้ ซึ่งสามารถทำงานร่วมกับเฟรมเวิร์กใดก็ได้หรือไม่มีเฟรมเวิร์กเลย
ข้อมูลโปรเจกต์
ดาว
13.1K
Forks
848
License
ไม่ระบุ
อัปเดต GitHub ล่าสุด
28 ก.ค. 2569
เพิ่มใน GetNotes
14 ก.ค. 2569
Repository
stenciljs/core
รูปแบบ
เหมาะกับงาน
เหมาะกับอาชีพ
Ecosystem
Angular · React · TypeScript · Vue
แปลและเรียบเรียงโดย AI
เนื้อหาฉบับภาษาไทย
ใช้อ่านเพื่อทำความเข้าใจเบื้องต้น โปรดตรวจสอบรายละเอียดสำคัญกับเอกสารต้นฉบับด้านล่าง

เริ่มต้นใช้งาน
เริ่มต้นโปรเจกต์ใหม่โดยทำตามคู่มือ Getting Started ฉบับย่อของเรา เรายินดีรับฟังความคิดเห็นจากคุณ! หากคุณมีข้อเสนอแนะหรือพบปัญหาในการใช้ Stencil โปรดแจ้ง issue ใน repository นี้
ตัวอย่าง
คอมโพเนนต์ของ Stencil มีลักษณะคล้ายกับคอมโพเนนต์ React ที่ใช้คลาส โดยมีการเพิ่ม TypeScript decorators เข้ามา:
import { Component, Prop, h } from '@stencil/core';
@Component({
tag: 'my-component', // ชื่อของแท็ก HTML แบบกำหนดเองของคอมโพเนนต์
styleUrl: 'my-component.css', // สไตล์ CSS ที่จะนำไปใช้กับคอมโพเนนต์
shadow: true, // คอมโพเนนต์นี้ใช้ ShadowDOM
})
export class MyComponent {
// คอมโพเนนต์รับอาร์กิวเมนต์สองตัว:
@Prop() first: string;
@Prop() last: string;
// HTML ต่อไปนี้จะถูกเรนเดอร์เมื่อมีการใช้งานคอมโพเนนต์ของเรา
render() {
return (
<div>
Hello, my name is {this.first} {this.last}
</div>
);
}
}คอมโพเนนต์ด้านบนสามารถใช้งานได้เหมือนกับองค์ประกอบ HTML อื่นๆ:
<my-component first="Stencil" last="JS"></my-component>เนื่องจาก Stencil สร้าง Web Components จึงสามารถทำงานได้ในเฟรมเวิร์กหลักใดๆ หรือแม้กระทั่งไม่มีเฟรมเวิร์กเลย ในหลายกรณี Stencil สามารถใช้แทนเฟรมเวิร์กฟรอนต์เอนด์แบบดั้งเดิมได้โดยตรง แม้ว่าการใช้งานในลักษณะนั้นจะไม่ใช่ข้อบังคับก็ตาม
การร่วมสนับสนุน
ขอบคุณสำหรับความสนใจในการร่วมสนับสนุน! โปรดสละเวลาอ่านแนวทางของเราสำหรับการ ร่วมสนับสนุน เราได้จัดทำเอกสารทางเทคนิคที่ครอบคลุมสำหรับผู้ร่วมสนับสนุน ซึ่งอธิบายสถาปัตยกรรมภายในของ Stencil รวมถึงคอมไพเลอร์, รันไทม์, ระบบบิลด์ และส่วนประกอบหลักอื่นๆ ในไดเรกทอรี /docs โปรดทราบว่าโปรเจกต์นี้เผยแพร่พร้อมกับ Contributor Code of Conduct การเข้าร่วมในโปรเจกต์นี้ถือว่าคุณตกลงที่จะปฏิบัติตามข้อกำหนด
เอกสารโปรเจกต์
อ่านเอกสารต้นฉบับ
README วิธีติดตั้ง วิธีใช้งาน และข้อกำหนดจาก repository ต้นฉบับ

Getting Started
Start a new project by following our quick Getting Started guide. We would love to hear from you! If you have any feedback or run into issues using Stencil, please file an issue on this repository.
Examples
A Stencil component looks a lot like a class-based React component, with the addition of TypeScript decorators:
import { Component, Prop, h } from '@stencil/core';
@Component({
tag: 'my-component', // the name of the component's custom HTML tag
styleUrl: 'my-component.css', // css styles to apply to the component
shadow: true, // this component uses the ShadowDOM
})
export class MyComponent {
// The component accepts two arguments:
@Prop() first: string;
@Prop() last: string;
//The following HTML is rendered when our component is used
render() {
return (
<div>
Hello, my name is {this.first} {this.last}
</div>
);
}
}The component above can be used like any other HTML element:
<my-component first="Stencil" last="JS"></my-component>Since Stencil generates web components, they work in any major framework or with no framework at all. In many cases, Stencil can be used as a drop in replacement for traditional frontend framework, though using it as such is certainly not required.
Contributing
Thanks for your interest in contributing! Please take a moment to read up on our guidelines for contributing. We've created comprehensive technical documentation for contributors that explains Stencil's internal architecture, including the compiler, runtime, build system, and other core components in the /docs directory. Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.
