Front End Cross-Frameworks Framework - 前端跨框架跨平台框架

Overview

English | 简体中文

omi

omi

Omi - Front End Cross-Frameworks Framework

Merge Web Components, JSX, Virtual DOM, Functional style, observe or Proxy into one framework with tiny size and high performance. Write components once, using in everywhere, such as Omi, React, Preact, Vue or Angular.

Omiu

Cross-Frameworks and Cross-Themes UI Components powered by Omi

Name Status Example Docs
@omiu/button omiu-button-status CodePen Button Docs
@omiu/icon omiu-icon-status Icon Online Icon Docs
@omiu/tabs omiu-tabs-status CodePen Tabs Docs
@omiu/radio omiu-radio-status CodePen Radio Docs
@omiu/link omiu-link-status CodePen Link Docs
@omiu/checkbox omiu-checkbox-status CodePen Checkbox Docs
@omiu/hamburger-menu omiu-hamburger-menu-status CodePen HamburgerMenu Docs
@omiu/input omiu-input-status CodePen Input Docs
@omiu/tree omiu-tree-status CodePen Tree Docs
@omiu/pagination omiu-pagination-status CodePen Pagination Docs
@omiu/loading omiu-loading-status CodePen Loading Docs
@omiu/toast omiu-toast-status CodePen Toast Docs
@omiu/action-sheet omiu-action-sheet-status CodePen ActionSheet Docs
@omiu/switch omiu-switch-status CodePen Switch Docs
@omiu/color-picker omiu-color-picker-status CodePen ColorPicker Docs
@omiu/chart omiu-chart-status CodePen Chart Docs
@omiu/toggle-icon omiu-toggle-icon-status CodePen ToggleIcon Docs
@omiu/o-icon omiu-o-icon-status CodePen OIcon Docs
@omiu/badge omiu-badge-status CodePen Badge Docs
@omiu/avatar omiu-avatar-status CodePen Avatar Docs
@omiu/breadcrumb omiu-breadcrumb-status CodePen Breadcrumb Docs
@omiu/bottom-nav omiu-bottom-nav-status CodePen BottomNav Docs
@omiu/transition omiu-transition-status CodePen Transition Docs
@omiu/dialog omiu-dialog-status CodePen Dialog Docs
@omiu/dialog-extention omiu-dialog-extention-status CodePen DialogExtention Docs
Coming...
Coming...

Quick Preview

Pass data through the component tree without having to pass props down manually at every level by store, auto update the view on demand.

import { define, render } from 'omi'

class Store {
  data = {
    count: 1
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

define('my-counter', _ => (
  <div>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
  </div>
), {
    use: ['count'], 
    //or using useSelf, useSelf will update self only, exclude children components
    //useSelf: ['count'], 
    css: `span { color: red; }`,
    installed() {
      console.log('installed')
    }
  })

render(<my-counter />, 'body', new Store)
  • <my-counter></my-counter> can be used in any framework or no framework, such as document.createElement('my-counter')

You can also use useSelf, useSelf only updates itself. When using useSelf, the corresponding attributes are accessed through usingSelf in JSX.

You can also implement computed props through compute, such as:

define('my-counter', _ => (
  <div>
    <button onClick={_.store.sub}>-</button>
    <span>{_.store.data.count}</span>
    <button onClick={_.store.add}>+</button>
    <div>Double: {_.computed.doubleCount}</div>
  </div>
), {
    use: ['count'],
    compute: {
      doubleCount() {
        return this.count * 2
      }
    }
  })

Path is also supported:

class Store {
  data = {
    list: [
      { name: { first: 'dnt', last: 'zhang' } }
    ]
  }
}

...
...

define('my-counter', _ => (
  ...
  ...
), {
    use: [
      'list[0].name', //Direct string path dep, accessible through this.using[0] 
    ],
    compute: {
      fullName() {
        return this.list[0].name.first + this.list[0].name.last
      }
    }
  })

Multi-store injection

import { define, render } from 'omi'

define('my-app', _ => {
  const store = _.store.storeA
  const { data, add, sub } = store
  return (
    <p>
      Clicked: {data.count} times
      <button onClick={add}>+</button>
      <button onClick={sub}>-</button>

      <div>
        {_.store.storeB.data.msg}
        <button  onClick={_.store.storeB.changeMsg}>
          change storeB's msg
        </button>
      </div>
    </p>
  )
}, {
  useSelf: {
    storeA: ['count', 'adding'],
    storeB: ['msg']
  }
})

const storeA = new class Store {
  data = {
    count: 0,
    adding: false
  }
  sub = () => {
    this.data.count--
  }
  add = () => {
    this.data.count++
  }
}

const storeB = new class Store {
  data = {
    msg: 'abc'
  }
  changeMsg = () => {
    this.data.msg = 'bcd'
  }
}

render( <my-app /> , 'body', {
  storeA,
  storeB
})

How to Multi-store injection with compute and computed? Very simple:

define('my-app', _ => {
  const store = _.store.storeA
  const { data, add, sub } = store
  return (
    <p>
      Clicked: {data.count} times
      <button onClick={add}>+</button>
      <button onClick={sub}>-</button>

      <div>
        {_.store.storeB.data.msg}
        <button onClick={_.store.storeB.changeMsg}>
          change storeB's msg
        </button>
      </div>

      <div>{_.computed.dobuleCount}</div>
      <div>{_.computed.reverseMsg}</div>
    </p>
  )
}, {
    useSelf: {
      storeA: ['count', 'adding'],
      storeB: ['msg']
    },
    compute: {
      dobuleCount() {
        return this.storeA.data.count * 2
      },
      reverseMsg() {
        return this.storeB.data.msg.split('').reverse().join('')
      }
    }
  })

API and Hooks

define('my-component', _ => (
  ...
  ...
), {
    use: ['count', 'path.a', 'path[1].b'],
    useSelf: ['path.c', 'path[1].d'],
    compute: {
      doubleCount() {
        return this.count * 2
      }
    },
    css: 'h1 { color: red; }',
    propTypes: { },
    defaultProps: { },
    isLightDom: true, //default is false

    //life cycle
    install() { }, 
    installed() { }, 
    uninstall() { }, 
    receiveProps() { },
    beforeUpdate() { }, 
    updated() { }, 
    beforeRender() { }, 
    rendered() { }, 

    //custom methods
    myMethodA() { },
    myMethodB() { }

  })

Inject use or useSelf through prop

<my-counter use={['count']} ></my-counter>

Ecosystem of Omi

💯 Base

Project Description
omi-docs and codepen and webcomponents.dev Omi official documents
omix 小程序全局状态管理框架,数据触手可及,状态无处遁形
omim Cross frameworks and themes components.(DOCS & REPL && JOIN US!)
omi-kbone 使用 omi + kbone 多端开发(小程序和Web)的贪吃蛇游戏。
omio Omi for old browsers with same api(IE8+)
omiv 1kb store system for Vue apps. SSR Now
omis Omis + React
omi-ssr Server-side rendering(support omio only)
omi-router Omi official router in 1KB js
omi-cli Project scaffolding. → Base Templates and → Other Templates
omi-devtools Browser DevTools extension
omiu Simple Omi UI
omil Webpack loader for Omi.js components.(DOCS)
omi-snippets A beautify VSCode extension for .omi or .eno file, Install now!
obaa or JSONPatcherProxy Observe or Proxy any object's any change

🐍 Snake MVP

Project Description
omi-snake & → Touch the demo The Snake-Eating Game Based on MVP Architecture Written by Omi
omi-kbone-snake omi-kbone 写的 MVP 架构的跨端贪吃蛇游戏,支持小程序和 H5
Preact-snake & → Touch the demo The Snake-Eating Game Based on MVP Architecture Written by Preact + Preact-CSS + Omis
[P]react-snake & → Touch the demo The Snake-Eating Game Based on MVP Architecture Written by React/Preact
vue-snake The Snake-Eating Game Based on MVP Architecture Written by Vue + Omiv
omix-snake The Snake-Eating Game Based on MVP Architecture Written by Omix

👍 Mini Program(小程序)

Project Description
omix 小程序全局状态管理框架,数据触手可及,状态无处遁形
react-kbone 直接使用 React 开发小程序或 Web,基于 kbone
preact-kbone 直接使用 Preact 开发小程序或 Web,基于 kbone
omi-cloud 小程序•云开发
omip 直接使用 Omi 开发小程序或 H5 SPA
mps 原生小程序增强框架(JSX + Less 输出 WXML + WXSS),也支持 QQ 轻应用
cax 小程序 Canvas 和 SVG 渲染引擎
omi-mp 通过微信小程序开发和生成 Web 单页应用(H5 SPA)
westore 小程序状态管理
comi 小程序代码高亮和 markdown 渲染组件
wx-touch-event 基于 AlloyFinger 改造的小程序手势解决方案

📚 Other

Project Description
omi-piano Build piano with Omi and Omi Snippets, Enjoy now!
omi-chart Simple HTML5 Charts using chart-x tag.
md2site Static Site Generator with markdown powered by Omio.
omi-30-seconds Useful Omi snippets that you can understand in 30 seconds.
omi-canvas Perfect fusion of web components, jsx and canvas.
omi-swiper Omi + Swiper
omi-vscode VSCode extension for omi, Install now!
omi-ex Omi.js extension(TypeScript)
omi-transform Omi / css3transform integration. Made css3 transform super easy in your Omi project.
omi-finger Support touch and gesture events in your Omi project.
omi-touch Smooth scrolling, rotation, pull to refresh and any motion for the web.
omi-native Render web components to native
omi-i18n Internationalization solution for omi.js using i18next ecosystem
omi-page Tiny client-side router by page
omie Build cross platform desktop apps with Omi.js and Electron.js
omi-cv Create a front-end engineer curriculum vitae, Get Started!
Soo Has same API as omi but is great alternative if you want to create custom elements without JSX, virtual DOM and store
CEE Fork from custom-elements-everywhere

Why Omi?

  • Tiny size and High performance
  • Cross frameworks(react, preact, vue, angular), components of omi are pure custom elements
  • One framework. Mobile & desktop & mini program
  • Stateless View Architecture Design
  • Be friendly to custom elements, you can pass false attributes to elements through string '0' or string 'false', you can pass object attributes to elements through : prefix and Omi.$
  • Easy two way binding by extend api
  • Supports TypeScript
  • Reactive data-binding
  • Native tap event support
  • Having Cross-frameworks UI components - omim
  • Excellent compatibility(IE8+) with omio
  • Enhanced CSS, rpx unit support base on 750 screen width
  • Compliance with browser trend and API design
  • Merge Web Components, JSX into one framework
  • Web Components can also be a data-driven view, UI = fn(data).
  • JSX is the best development experience (code intelligent completion and tip) UI Expression with least grammatical noise and it's turing complete(template engine is not, es template string is but grammatical noise is too loud)
  • Look at Facebook React vs Web Components,Omi combines their advantages and gives developers the freedom to choose the way they like
  • Shadow DOM or Light DOM merges with Virtual DOM, Omi uses both virtual DOM and real Shadow DOM to make view updates more accurate and faster
  • Scoped CSS's best solution is Shadow DOM, the community churning out frameworks and libraries for Scoped CSS (using JS or JSON writing styles such as Radium, jsxstyle, react-style; binding to webpack using generated unique className filename-classname-hash, such as CSS Modules, Vue), are hack technologies; and Shadow DOM Style is the perfect solution.
  • The original Path Updating store system. Proxy-based automatic accurate update, low power consumption, high degree of freedom, excellent performance, easy integration of requestIdleCallback,It will automatically update UI partially when data is changed

Compare TodoApp by Omi and React, Omi and React rendering DOM structure:

Omi React Omio
Omi React Omio

Omi uses Shadow DOM or Light DOM based style isolation and semantic structure.

Useful Resources

Title Name Other language Related
Web Components bookmarks
Snake-Eating Game Making with Web Components of Omi and MVP Architecture
Constructable Stylesheets: seamless reusable styles
Web Components specifications
Web Components in a Nutshell
Using Web Components with React in 2019
Using Web Components in React
Styling We Components Using A Shared Style Sheet
Developer Tools support for Web Components in Firefox 63
Develop W3C Web Components with WebAssembly
60FPS Animation In Omi 简体中文 한국어
Render Web Components To Native 简体中文 한국어
Shadow Dom In Depth 简体中文
Part Theme Explainer 求翻译
Web Components MDN 简体中文
Web Components Google
Web Components Org
Web Components: the Right Way
Proxy MDN 简体中文 한국어
CSS Variables 简体中文 한국어
CSS Shadow Parts
Platform HTML5
Using requestIdleCallback 简体中文 A polyfill
The Power Of Web Components 简体中文
ShadowRoot 简体中文

Overview of the Readme

Add Omi in One Minute

This page demonstrates using Omi with no build tooling, directly run in the browser.

<!DOCTYPE html>
<html>

<head>
  <title>Omi demo without transpiler</title>
</head>

<body>
  <script src="https://unpkg.com/omi"></script>
  <script>
    const { define, render, h } = Omi

    class Store {
      data = {
        count: 1
      }
      sub = () => {
        this.data.count--
      }
      add = () => {
        this.data.count++
      }
    }

    define('my-counter', _ => (
      h(h.f, null,
        h('button', {
          onClick: _.store.sub
        }, '-'),
        h('span', null, _.store.data.count),
        h('button', {
          onClick: _.store.add
        }, '+')
      )
    ), {
      use: ['count'],
      //or using useSelf, useSelf will update self only, exclude children components
      //useSelf: ['count'],
      css: `span { color: red; }`,
      installed() {
        console.log('installed')
      }
    })

    render(h('my-counter'), 'body', new Store)

  </script>
</body>

</html>

Omi Store provides a way to pass data through the component tree without having to pass props down manually at every level, injected from the root component and shared across all subcomponents. It's very simple to use:

You can also use my-counter tag directly in HTML:

<body>
  <my-counter></my-counter>
</body>

Getting Started

Install

$ npm i omi-cli -g    # install cli
$ omi init my-app     # init project
$ cd my-app           
$ npm start           # develop
$ npm run build       # release

npx omi-cli init my-app is also supported(npm v5.2.0+).

Directory description:

├─ config
├─ public
├─ scripts
├─ src
│  ├─ assets
│  ├─ elements    //Store all custom elements
│  ├─ store       //Store all this store of pages
│  ├─ admin.js    //Entry js of compiler,will build to admin.html
│  └─ index.js    //Entry js of compiler,will build to index.html

Scripts

"scripts": {
    "start": "node scripts/start.js",
    "build": "PUBLIC_URL=. node scripts/build.js",
    "build-windows": "set PUBLIC_URL=.&& node scripts/build.js",
    "fix": "eslint src --fix"
}

You can set up the PUBLIC_URL, such as:

...
"build": "PUBLIC_URL=https://fe.wxpay.oa.com/dv node scripts/build.js",
"build-windows": "set PUBLIC_URL=https://fe.wxpay.oa.com/dv && node scripts/build.js",
...

Switch omi, omio and reomi

Add or remove the alias config in package.json to switch omi and omio:

"alias": {
  "omi": "omio"
}

Project Template

Template Type Command Describe
Base Template(v3.3.0+) omi init my-app Basic omi or omio(IE8+) project template.
Base Template with snapshoot omi init-snap my-app Basic omi or omio(IE8+) project template with snapshoot prerendering.
TypeScript Template(omi-cli v3.3.0+) omi init-ts my-app Basic template with typescript.
Mobile Template omi init-weui my-app Mobile web app template with weui and omi-router.
Kbone Template omi init-kbone my-app Developing mini program or web using omi.

Hello Element

Define a custom element by extending WeElement base class:

import { define, WeElement } from 'omi'

define('hello-element', class extends WeElement {
  onClick = evt => {
    // trigger CustomEvent
    this.fire('abc', { name: 'dntzhang', age: 12 })
    evt.stopPropagation()
  }

  //If you need to use <hello-element></hello-element> directly in html, you must declare propTypes
  static propTypes = {
    msg: String
  }

  static css = `
      div {
        color: red;
        cursor: pointer;
      }`

  render(props) {
    return (
      <div onClick={this.onClick}>
        Hello {props.msg}
        <div>Click Me!</div>
      </div>
    )
  }
})

Using hello-element:

import { define, render, WeElement } from 'omi'
import './hello-element'

define('my-app', class extends WeElement {
  data = { abc: 'abc' }

  // define CustomEvent Handler
  onAbc = evt => {
    // get evt data by evt.detail
    this.data.abc = ' by ' + evt.detail.name
    this.update()
  }

  static css = `
      div{
          color: green;
      }`
  }

  render(props, data) {
    return (
      <div>
        Hello {data.abc}
        <hello-element
          onAbc={this.onAbc}
          msg="WeElement"
        />
      </div>
    )
  }
})

render(<my-app name="Omi v4.0" />, 'body')

Tell Babel to transform JSX into Omi.h() call:

{
  "presets": ["env", "omi"]
}

The following two NPM packages need to be installed to support the above configuration:

"babel-preset-env": "^1.6.0",
"babel-preset-omi": "^0.1.1",

If you use babel7, you can also use the following packages and configuration:

npm install --save-dev @babel/preset-env
npm install --save-dev @babel/preset-react
{
  "presets": [
    "@babel/preset-env",
    [
      "@babel/preset-react",
      {
        "pragma": "Omi.h",
        "pragmaFrag": "Omi.h.f"
      }
    ]
  ]
}

If you don't want to write CSS in JS, you can use to-string-loader of webpack. For example, the following configuration:

{
  test: /[\\|\/]_[\S]*\.css$/,
  use: [
    'to-string-loader',
    'css-loader'
  ]
}

If your CSS file starts with "_", CSS will use to-string-loader, such as:

import { tag, WeElement render } from 'omi'

define('my-app', class extends WeElement {

  css = require('./_index.css')
  ...
  ...
  ...

You can also forget the tedious configuration and use omi-cli directly, no need to configure anything.

TypeScript Auto Complete

import { h, WeElement, tag, classNames } from 'omi';
import * as styles from './_index.less';

interface ButtonProps {
  href?: string,
  disabled?: boolean,
  type?: 'default' | 'primary' | 'danger',
  htmltype?: 'submit' | 'button' | 'reset',
  onClick?: (e: any) => void
}

const TAG = 'o-button'

declare global {
  namespace JSX {
    interface IntrinsicElements {
      [TAG]: Omi.Props & ButtonProps
    }
  }
}

@tag(TAG)
export default class oButton extends WeElement<ButtonProps> {
...
...
...

omi

Lifecycle

Lifecycle method When it gets called
install before the component gets mounted to the DOM
installed after the component gets mounted to the DOM
uninstall prior to removal from the DOM
beforeUpdate before update
updated after update
beforeRender before render()
receiveProps parent element re-render will trigger it, return false will prevent update action

Debugging

Easy to debug via Omi DevTools Extension [Install from Chrome WebStore], using Omi DevTools you can simply debug and manage your UI without any configuration. Just install and debug.

Since Omi uses Web Components and Shadow-DOM, it doesn't need to have another elements panel such as React has. It just adds a panel to the Elements' sidebar and it's powerful as much as React DevTools.

Omi DevTools

View registered elements

console.log(Omi.elements)

Browsers Support

Omio - Omi for old browsers(IE8+)

Omi works in the latest two versions of all major browsers: Safari 10+, IE 11+, and the evergreen Chrome, Firefox, and Edge.

→ Browsers Support

→ Polyfills

<script src="https://unpkg.com/@webcomponents/[email protected]/webcomponents-bundle.js"></script>

Contribution

Build a example:

npm start example_name

Build omi:

npm run build

Unit testing

npm run test

Contributors

Any form of contribution is welcome. The above contributors have been officially released by Tencent.

We very much welcome developers to contribute to Tencent's open source, and we will also give them incentives to acknowledge and thank them. Here we provide an official description of Tencent's open source contribution. Specific contribution rules for each project are formulated by the project team. Developers can choose the appropriate project and participate according to the corresponding rules. The Tencent Project Management Committee will report regularly to qualified contributors and awards will be issued by the official contact.

Design philosophy

The Omi design was driven by The Zen of Python, by Tim Peters philosophy:

  • Beautiful is better than ugly.
  • Explicit is better than implicit.
  • Simple is better than complex.
  • Complex is better than complicated.
  • Flat is better than nested.
  • Sparse is better than dense.
  • Readability counts.
  • Special cases aren't special enough to break the rules.
  • Although practicality beats purity.
  • Errors should never pass silently.
  • Unless explicitly silenced.
  • In the face of ambiguity, refuse the temptation to guess.
  • There should be one—and preferably only one—obvious way to do it.
  • Although that way may not be obvious at first unless you're Dutch.
  • Now is better than never.
  • Although never is often better than right now.
  • If the implementation is hard to explain, it's a bad idea.
  • If the implementation is easy to explain, it may be a good idea.
  • Namespaces are one honking great idea—let's do more of those!

Core Maintainers

Please contact us for any questions.

Thanks

License

MIT © Tencent

Comments
  • Created a mini library using Omi

    Created a mini library using Omi

    Hi, I created a library using omi similar to hyperapp for functional programming. Please let me know your feedback.

    https://codesandbox.io/s/omi-ts-bhq64

    Thanks for awesome Omi.

    opened by kethan 18
  • 模块导出以及一些疑问

    模块导出以及一些疑问

    omi-cli 生成项目代码

    src/elements/app-intro/index.js

    import { tag, WeElement } from 'omi'
    import style from './_index.css'
    
    @tag('app-intro')
    class AppIntro extends WeElement {
      css() {
        return style + `
        code{
          color: ${Math.random() > 0.5 ? 'red' : 'blue'}
        }`
      }
    
      render(props, data) {
        return (
          <p class="app-intro">
              To get started, edit <code>src/elements/*/*.*</code> and save to reload.
            </p>
        )
      }
    }
    

    src/elements/app/index.js

    import { tag, WeElement } from 'omi'
    import logo from './logo.svg'
    import style from './_index.css'
    import '../app-intro'
    
    @tag('my-app')
    class MyApp extends WeElement {
    
      static get data() {
        return { name: '' }
      }
    
      clickHandler = () => {
        this.store.rename('Omi V4.0')
      }
    
      css() {
        return style 
      }
    
      render(props, data) {
        return (
          <div class="app">
            <header class="app-header">
              <img src={logo} onClick={this.clickHandler} class="app-logo" alt="logo" />
              <h1 class="app-title">Welcome to {data.name}</h1>
            </header>
            <app-intro></app-intro>
          </div>
        )
      }
    }
    

    为什么没有模块导出, 但是omi-cli 正确使用webpack 完全编译了, 是使用了什么黑魔法吗? tag my-app 只在组件内部注解了名称, 但是文件夹名称又是app. 是omijs 创造了一种新的模块化 components 吗。 我在使用其他组件时 是不是也需要翻进代码里查找@tag. omijs components 是以目录名为组织还是以@tag为组织单个组件?或者index.js ? main.js ? 一个js文件了可以写多个@tag吗?

    为什么omi-cli 中生成代码有的是2个空格锁进, 有的是4个,8个锁进? 你们如何解决代码被eslint 提示 'AppIntro' is declared but never used.

    opened by image72 14
  • ie8 怎么兼容?

    ie8 怎么兼容?

    我已经在index页面上引入了es5-shim.js

    <!DOCTYPE html>
    <html>
    <head>
        <meta charset="UTF-8">
        <title>Omi</title>
        <script src="js/es5-shim.min.js"></script>
        <link rel="stylesheet" href="css/index-ef14a72eca.css">
    </head>
    <body>
    
        <script src="js/vendor.9da31384.js"></script>
    
        <script src="js/omi.27cdf71e.js"></script>
    
        <script src="js/index.25f7b79d.js"></script>
    
    </body>
    </html>
    

    但是在运行的时候还是出现了错误。

    错误如下: 网页错误详细信息

    用户代理: Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1; WOW64; Trident/4.0; SLCC2; .NET CLR 2.0.50727; .NET CLR 3.5.30729; .NET CLR 3.0.30729; Media Center PC 6.0; .NET4.0C; .NET4.0E; InfoPath.2) 时间戳: Thu, 30 Mar 2017 07:39:28 UTC

    消息: 对象不支持此操作 行: 1059 字符: 2 代码: 0 URI: file:///D:/screwspace/webfront/omi/test/dist/js/omi.27cdf71e.js

    消息: 对象不支持此属性或方法 行: 1 字符: 1 代码: 0 URI: file:///D:/screwspace/webfront/omi/test/dist/js/omi.27cdf71e.js

    消息: 缺少标识符、字符串或数字 行: 16 字符: 79 代码: 0 URI: file:///D:/screwspace/webfront/omi/test/dist/js/index.25f7b79d.js

    应该还是兼容性的问题。

    opened by louisscrew 14
  • omi-html

    omi-html

    屏幕快照 2019-04-26 下午10 24 01

    omi-html模块能顺手像omi那样打包成dist文件夹导出吗,这样比较方便webpack中导入,所以希望有空更新下这个模块,谢谢~

    {
      "name": "omi-html",
      "version": "0.3.0",
      "description": "Omi Htm integration.",
      "main": "dist/omi-html.js",
      "scripts": {
        "counter": "webpack -w",
        "build": "webpack -w",
        "build-min": "webpack -w"
       // code...
      }
    }
    
    opened by Wscats 13
  • 请问如何在自定义组件的install方法里,接收并验证传递给组件的props参数呢?

    请问如何在自定义组件的install方法里,接收并验证传递给组件的props参数呢?

    从pages里的页面调用 自定义组件,并传递 参数,在自定义组件的render中可以直接使用 {this.props.isshow} 这种方式来获取变量值,那么请问,如何在render之前,接收props里的isshow参数,并对他验证,以对其他数据进行处理呢?谢谢!

    在install()方法里面,直接使用 this.props.isshow,小程序那边总是提示无法找到属性 isshow。

    opened by jzsjiale 12
  • 精巧小程序框架 omix,支持中心化和去中心化

    精巧小程序框架 omix,支持中心化和去中心化

    初次发现这个小巧的框架,很是喜欢,就是初次有点不懂运用。

    文档地址: https://github.com/Tencent/omi/tree/master/packages/omix

    去中心化,似乎就没有了整个的数据仓库了。 中心化,就把每个页面的所有data都中心化了。 有没有办法,我只想部分数据中心化,其他的去中心化呢

    opened by hoboy0313 11
  • 无法获得 static get data() 中的属性值

    无法获得 static get data() 中的属性值

    https://github.com/Tencent/omi/blob/master/README.CN.md 当我按照该文档进行的时候,出现了如下的错误:

    1. 安装全局 omi-cli 并使用 omi init-ts 创建了 一个ts 的项目.
    2. 删除自动生成的 index.tsx 和 hello-omi.tsx 文件
    3. 将 快速入门下 的 Hello Element 和 使用该 element 的内容 分别 放入 hello-element.tsx , 和 index.tsx
    4. 在vscode 编辑器中 提示如下: image
    5. npm run start , 编译出现如下错误 image 当我将 4 中的 this.data.abc = ' by ' + evt.detail.name 注释之后, 则可以编译通过. 显示正常.

    另外, 当我给tag 命名成单个单词, 如 hello 而非 hello-element 或 hello-world 时, 会出现如下错误: image

    请问, 是我哪里的 打开方式不对么? 求解答.谢谢

    TypeScript 
    opened by Sihan-Tan 10
  • 你好,使用omi-mp编译报错

    你好,使用omi-mp编译报错

    Failed to compile ./src/mp/pages/index/index.js Syntax error: C:/Users/no1/my-app/src/mp/pages/index/index.js: Unexpected token (174:0)

    172 | customElements.define('we-index', Element) 173 |

    174 | } | ^ 175 | class Element extends WeElement { 176 | data = mpOption().data 177 |

    opened by coderguohuo 9
  • 子组件在初始化时使用父组件的option时,内存溢出异常

    子组件在初始化时使用父组件的option时,内存溢出异常

    为了更好联动关系,我写了三个组件,App、ItemList以及ListTitle 其中ItemList和ListTitle都属于App的子组件。ListTitle动态显示列表的数量。为了当ItemList发生变化,及时的更新到ListTitle上,我用了一个比较慵懒的方法,就是共享App的option。代码如下:

    <!DOCTYPE html>
    <html>
    <head>
    <meta charset="utf-8">
    <title>组件的嵌套</title>
    <script type="text/javascript" src="js/jquery-1.11.3.js"></script>
    <script type="text/javascript" src="js/nuclear.js"></script>
    <script type="text/javascript" src="js/template.js"></script>
    </head>
    <body>
    <div id="demo"></div>
    <script type="text/javascript">
    //第三方模板的替换
        Nuclear.render = function (tpl, data) {
            return template.compile(tpl)(data);
        };
    
        var ListTitle = Nuclear.create({
            render:function(){
                return '<div>List num {{users.length}}</div>'
            }
        });
    
        var ItemList = Nuclear.create({
            deleteEvent: function (index) {
                this.option.users.splice(index, 1);
            },
            add: function () {
                this.option.users.push({ "name": "333" });
            },
            render: function () {
                return '\
            <ul>\
                {{each users as item index}}\
                <li>{{item.name}} <a onclick="deleteEvent({{index}})" href="javascript:void(0)">delete</a></li>\
                {{/each}}\
            </ul>\
            ';
            }
        });
        var App = Nuclear.create({
            install: function () {
                var _this = this;
                // var listData = _this.pureOption.users;
                // this.childrenOptions = [
                //     _this.pureOption
                //     ,_this.pureOption
                // ];
    
                this.childrenOptions = [
                    {users:_this.pureOption.users}
                    ,{users:_this.pureOption.users}
                ];
            },
            add: function () {
                this.itemList.option.users.push({ name: 'aaa' });
            },
            clear: function () {
                this.itemList.option.users = [];
            },
            render: function () {
                return '\
                <div nc-id="app">\
                    <child nc-constructor="ListTitle" nc-name="listTitle"></child>\
                    <child nc-constructor="ItemList" nc-name="itemList"></child>\
                    <div><a onclick="add()" href="javascript:void(0)">添加</a></div>\
                    <div><a onclick="clear()" href="javascript:void(0)">清空</a></div>\
                </div>\
            ';
            }
        });
        var app = new App({
            users: [{
                name: 'item1'
            }, {
                name: 'item2'
            }, {
                name: 'item3'
            }]
        }, "#demo");
    
    
    </script>
    </body>
    </html>
    
    

    可是上述代码在运行时直接就报错了。内容如下: nuclear.js:1453 Uncaught SyntaxError: Invalid regular expression: /\bforEach\b/: Stack overflow(…)

    问题在于下面的这个代码 this.listTitle = new ListTitle(this.option); this.itemList = new ItemList(this.option);

    只要我注释其中一条就可以了,只要是有两个初始化则就报错。

    opened by louisscrew 9
  • 页面销毁后,data数据并未重置(二级数据)

    页面销毁后,data数据并未重置(二级数据)

    @dntzhang

    <button bind:tap="gotoTest">测试</button>
    
    gotoTest() {
            wx.navigateTo({
                url: '/pages/test?text=1',
            })
        },
    

    然后test页面:

    create.Page({
        context: { emitter: create.emitter },
        data: {
            logs: {
                motto: '',
                msg: [],
            },
        },
        onLoad(e) {
            console.log('test 页面 onload', e, '同时获取motto值:', this.oData.logs)
            this.oData.e = e
        },
        onUnload() {
            console.log('test 页面 onUnload..此时应该销毁该页面data中所有值')
        },
        handleInput(e) {
            this.oData.logs.motto = e.detail.value
            console.log('监控到输入:', this.oData.logs.motto)
        },
    })
    

    重点是:motto属性是在logs下,输入一个值,赋予motto,然后左上角返回,再次进入就可以看到效果了。

    • data一级属性没毛病
    opened by Lingouzi 8
  • 计算属性

    计算属性

    怎么在 omi-mp-create 里实现类似 vue computed(计算属性)?

    https://github.com/b5156/wxapp-computed/

    这里的方案可以借鉴进来吗?

    像 mobx 里 computed 就是自带的:https://cn.mobx.js.org/refguide/computed-decorator.html

    opened by transtone 8
  • feat(scripts):add script quickly execute component commands

    feat(scripts):add script quickly execute component commands

    从心圆RFC中云游君给出的第一条额外建议中获得灵感 做出了第一版方便component开发的脚本cli 目前支持已支持:docs start build 命令

    该脚本位于主目录中,方便快捷开发组件 image docs: image start: image build: image

    另外发现某些组件库脚本命令不统一: image

    有部分feat待加入和完善,欢迎各位add code

    opened by BoyYangzai 1
  • RFC: OMI Todos 2022

    RFC: OMI Todos 2022

    OMIU Table

    • 排序(已支持)
    • 合并单元格
    • 筛选

    OMIU 表单

    • transfer 穿梭框
    • 相关表单组件完善
    • 快速表单生成

    OMI Admin 的结果页的图片换成 SVG,主题色变更,svg同时也会变色,SVG文件地址: https://github.com/Tencent/tdesign-vue-starter/tree/develop/src/assets

    OMI Admin 支持大日历,可以添加任务和管理日程,参考或使用 https://github.com/nhn/tui.calendar

    OMI Admin 支持看版,参考 https://www.youtube.com/watch?v=jx5hdo50a2M

    image

    OMI Admin 支持 omi playground

    • 主体功能已完成,可以加一些例子(比如 omi-router的例子)

    OMI Admin 集成 echarts

    OMI Admin 支持监控页面,全是监控曲线 image image

    OMI Grid Layout 组件,参考 react-grid-layout 和 vue-grid-layout

    OMI Admin 白天和黑夜模式切换

    OMI Admin 内容区域统一使用灰色底

    opened by dntzhang 0
  • RFC : modern omi in 2022

    RFC : modern omi in 2022

    这里提出几个 RFC 为腾讯开源人才培养计划的 Omi 项目作为预热,用来优化 Omi 生态开发的整个流程,优化 Omi 开发工具链,以及优化 Omi 组件库的整体结构。

    1. 尝试最低成本迁移到 monorepo 优化整个开发体验
    2. 移除强平台性依赖如 node-sass 等降低开发踩坑难度
    3. 优化整个组件库编译打包流程,尽可能收口同一个构建流程中。
    4. 优化整个脚手架开发体验 , 为后期的整个 proform protable 等复杂组件做铺垫
    5. 规范化代码检查与风格化
    6. omiu demo 调试开发优化
    opened by ChelesteWang 14
Releases(v6.25.10)
Dojo Framework. A Progressive Framework for Modern Web Apps

@dojo/framework Dojo is a progressive framework for modern web applications built with TypeScript. Visit us at dojo.io for documentation, tutorials, c

Dojo 549 Dec 25, 2022
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

Supporting Vue.js Vue.js is an MIT-licensed open source project with its ongoing development made possible entirely by the support of these awesome ba

vuejs 201.6k Jan 7, 2023
One framework. Mobile & desktop.

Angular - One framework. Mobile & desktop. Angular is a development platform for building mobile and desktop web applications using Typescript/JavaScr

Angular 85.6k Dec 31, 2022
Ember.js - A JavaScript framework for creating ambitious web applications

Ember.js is a JavaScript framework that greatly reduces the time, effort and resources needed to build any web application. It is focused on making yo

Ember.js 22.4k Jan 4, 2023
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

vue-next This is the repository for Vue 3.0. Quickstart Via CDN: <script src="https://unpkg.com/vue@next"></script> In-browser playground on Codepen S

vuejs 34.6k Jan 4, 2023
The tiny framework for building hypertext applications.

Hyperapp The tiny framework for building hypertext applications. Do more with less—We have minimized the concepts you need to learn to get stuff done.

Jorge Bucaran 18.9k Jan 1, 2023
🌱 React and redux based, lightweight and elm-style framework. (Inspired by elm and choo)

English | 简体中文 dva Lightweight front-end framework based on redux, redux-saga and react-router. (Inspired by elm and choo) Features Easy to learn, eas

null 16.1k Jan 4, 2023
Relay is a JavaScript framework for building data-driven React applications.

Relay · Relay is a JavaScript framework for building data-driven React applications. Declarative: Never again communicate with your data store using a

Facebook 17.5k Jan 1, 2023
A rugged, minimal framework for composing JavaScript behavior in your markup.

Alpine.js Alpine.js offers you the reactive and declarative nature of big frameworks like Vue or React at a much lower cost. You get to keep your DOM,

Alpine.js 22.5k Jan 2, 2023
The AMP web component framework.

AMP ⚡ ⚡ ⚡ ⚡ Metrics Tooling AMP is a web component framework for easily creating user-first websites, stories, ads, emails and more. AMP is an open so

AMP 14.9k Jan 4, 2023
A JavaScript Framework for Building Brilliant Applications

mithril.js What is Mithril? Installation Documentation Getting Help Contributing What is Mithril? A modern client-side JavaScript framework for buildi

null 13.5k Dec 28, 2022
The Aurelia 1 framework entry point, bringing together all the required sub-modules of Aurelia.

aurelia-framework Aurelia is a modern, front-end JavaScript framework for building browser, mobile, and desktop applications. It focuses on aligning c

aurelia 11.7k Jan 7, 2023
A modest JavaScript framework for the HTML you already have

Stimulus A modest JavaScript framework for the HTML you already have Stimulus is a JavaScript framework with modest ambitions. It doesn't seek to take

Hotwire 11.7k Dec 29, 2022
A functional and reactive JavaScript framework for predictable code

Cycle.js A functional and reactive JavaScript framework for predictable code Website | Packages | Contribute | Chat | Support Welcome Question Answer

Cycle.js 10.2k Jan 4, 2023
🐰 Rax is a progressive React framework for building universal application. https://rax.js.org

Rax is a progressive React framework for building universal applications. ?? Write Once, Run Anywhere: write one codebase, run with Web, Weex, Node.js

Alibaba 7.8k Dec 31, 2022
:steam_locomotive::train: - sturdy 4kb frontend framework

Choo ?? ?? ?? ?? ?? ?? Fun functional programming A 4kb framework for creating sturdy frontend applications Website | Handbook | Ecosystem | Contribut

choo 6.7k Jan 4, 2023
App development framework based on cocos creator3.1.1

todo: Waiting for English translation cx-cocos App development framework based on cocos creator3.1.1 一个基于cocos creator3.1.1的应用App和游戏开发框架 关键词:cocos cre

null 63 Dec 7, 2022
Frontend framework for creating reactive UIs using direct DOM manipulation. (WIP)

Cosmos Framework A frontend framework for creating reactive UIs using direct DOM manipulation. (Heavily WIP) How to get started with Cosmos Framework

CosmicMedia 5 Nov 6, 2022
Shoelace - A collection of professionally designed, every day UI components built on a framework-agnostic technology. 🥾

Shoelace A forward-thinking library of web components. Works with all frameworks ?? Works with CDNs ?? Fully customizable with CSS ?? Includes an offi

Shoelace 7.7k Dec 26, 2022