Web Components Framework - Web组件框架
English | 简体中文
import { render, signal, tag, Component, h } from 'omi'
const count = signal(0)
function add() {
count.value++
}
function sub() {
count.value--
}
@tag('counter-demo')
export class CounterDemo extends Component {
static css = 'span { color: red; }'
render() {
return (
<>
<button onClick={sub}>-</button>
<span>{count.value}</span>
<button onClick={add}>+</button>
</>
)
}
}Use this component:
import { h } from 'omi'
import './counter-demo'
render(<counter-demo />, document.body)
// or
import { CounterDemo, Other } from './counter-demo'
// Prevent tree Shaking when importing other things
render(<CounterDemo />, document.body)
// or
document.body.appendChild(document.createElement('counter-demo'))npm i omiTo quickly create an Omi + Vite + TS/JS project:
$ npx omi-cli init my-app # or create js project by: npx omi-cli init-js my-app
$ cd my-app
$ npm start # develop
$ npm run build # releaseTo quickly create an Omi + Router + Signal + Suspense + Tailwindcss + Vite + TS project:
$ npx omi-cli init-spa my-app
$ cd my-app
$ npm start # develop
$ npm run build # releaseomi - Implementation of omi framework.omi-form - Powerful, simple and cross frameworks form solution.lucide-omi - Lucide icon collection for omi.omiu - Hope to create the best web components. For example, the powerful vchart and vtableomi-router - Create SPA of omi framework.omi-cli - To quickly create an Omi + Vite + TS/JS project.omi-elements - Tailwind Element Omi UI KIT.omi-starter-spa - A starter repo for building single page app using Omi + OmiRouter + Tailwindcss + TypeScript + Vite + Prettier.omi-starter-ts - A starter repo for building web app or reusable components using Omi in TypeScript base on Vite.omi-starter-tailwind - A starter repo for building web app or reusable components using Omi + Tailwindcss + TypeScript + Vite.omi-starter-js - A starter repo for building web app or reusable components using Omi in JavaScript base on Vite.omi-vue - Vue SFC + Vite + OMI + OMI-WeUI.omi-weui - WeUI Components of omi.omi-auto-animate - Omi version of @formkit/auto-animate.omi-suspense - Handling asynchronous dependencies.omi-transition - Applying animations when an component is entering and leaving the DOM.omi-ripple - A lightweight component for adding ripple effects to user interface elements.snake-game-2tier - SNake Game with Signal classsnake-game-3tier - SNake Game with reactivity functionsomi-tutorial - Source code of omi tutorial.If you want to help the project grow, start by simply sharing it with your peers!
Thank you!
Data oriented programming
In data-oriented programming, the focus is on the data itself and the operations on the data, rather than the objects or data structures that hold the data. This programming paradigm emphasizes the change and flow of data, and how to respond to these changes. The TodoApp with reactivity functions is a good example of this, using the concepts of reactive programming, where the UI automatically updates to reflect changes in the data (i.e., the to-do list).
…vite.config.js:
import { defineConfig } from 'vite'
export default defineConfig({
esbuild: {
jsxInject: "import { h } from 'omi'",
jsxFactory: "h",
jsxFragment: "h.f"
}
})You can inject code during construction, so you don't have to manually export h.
The case of using Omi component in Vue is as follows:
my-counter.tsx:
…<script setup>
import { ref } from 'vue'
// import omi component
import './my-counter'
defineProps({
msg: String,
})
const count = ref(0)
const change = (e) => {
count.value = e.detail
}
</script>
<template>
<h1>{{ msg }}</h1>
<my-counter @change="change" :count="count" />
<p>
【Omi】
</p>
</template>If you fire the count-change in an Omi component:
this.fire('count-change', this.state.count)To use the component and listen for events in Vue:
<my-counter @count-change="change" :count="count" />…MIT © Tencent
omi-vueify包的chatbot组件里slot发生变更时不会触发webc父组件的更新
补充 omi-reactify 封装 omi tree组件实现 react 组件
补充 omi 单元测试(任意子模块)
升级omi cli的模板的Vite为最新版本
补充 reactive-signal 单元测试
omi-templates vite升到 v7
补充 omi-vueify 单元测试
传入类型是HTMLCollection,要如何解析到Omi里面?
OMI接收不了Vue传过来的方法
希望自定义事件可以支持携带: