145c9c3311 | ||
---|---|---|
asset | ||
dist | ||
docs | ||
example | ||
plugins | ||
scaffolding | ||
src | ||
test | ||
website | ||
.gitignore | ||
.travis.yml | ||
README.md | ||
index.html | ||
package.json | ||
webpack.config.js |
README.md
Open and modern framework for building user interfaces.
中文 | English
- 如果想体验一下Omi框架,请点击Omi Playground
- 如果想使用Omi框架,请阅读 Omi使用文档
- 如果想一起开发完善Omi框架,有更好的解决方案或者思路,请阅读 从零一步步打造web组件化框架Omi
- 关于上面的两类文档,如果你想获得更佳的阅读体验,可以访问Docs Website
- 如果你懒得搭建项目脚手架,可以试试Scaffolding for Omi,npm安装omis便可
- 如果你有Omi相关的问题可以New issue
- 如果想更加方便的交流关于Omi的一切可以加入QQ的Omi交流群(256426170)
生态
通过npm安装
npm install omi
Hello World
class Hello extends Omi.Component {
constructor(data) {
super(data);
}
style () {
return `
h1{
cursor:pointer;
}
`;
}
handleClick(target, evt){
alert(target.innerHTML);
}
render() {
return `
<div>
<h1 onclick="handleClick(this, event)">Hello ,{{name}}!</h1>
</div>
`;
}
}
Omi.render(new Hello({ name : "Omi" }),"body");
如果使用omi.lite.js版本(不包含mustachejs模板引擎)的话,也可以使用 ${this.data.name} 的方式。
你可以使用Omi.makeHTML来生成组件标签用于嵌套。
Omi.makeHTML('Hello', Hello);
那么你就在其他组件中使用,并且通过data-*的方式可以给组件传参,如:
...
render() {
return `
<div>
<div>Test</div>
<Hello data-name="Omi" />
</div>
`;
}
...
你可以使用 webpack + babel,在webpack配置的module设置babel-loader,立马就能使用ES6+来编写你的web程序。
当然Omi没有抛弃ES5的用户,你可以使用ES5的方式编写Omi。[点击这里试试ES5写Omi程序]
中文 | English
- If you want to experience the Omi framework, please click Omi Playground
- If you want to use the Omi framework,please read the Omi documentation
- If you want to develop and improve the Omi framework, there are better solutions or ideas, please read develop the Omi framework step by step
- If you want to get a better reading experience of the above two categories of documents, you can visitDocs Website
- If you are too lazy to build a project scaffolding, you can try Scaffolding for Omi
- If you have Any problems,please New issue
- If you want to be more convenient on the exchange of all Omi can join the QQ Omi exchange group (256426170)
Install
npm install omi
Hello World
class Hello extends Omi.Component {
constructor(data) {
super(data);
}
style () {
return `
h1{
cursor:pointer;
}
`;
}
handleClick(target, evt){
alert(target.innerHTML);
}
render() {
return `
<div>
<h1 onclick="handleClick(this, event)">Hello ,{{name}}!</h1>
</div>
`;
}
}
Omi.render(new Hello({ name : "Omi" }),"body");
You can use Omi.makeHTML to generate component tags for nesting.
Omi.makeHTML('Hello', Hello);
Then you can use it in other components, and pass parameter to the component through the data-* , such as:
...
render() {
return `
<div>
<div>Test</div>
<Hello data-name="Omi" />
</div>
`;
}
...
You can use webpack + babel,configure the babel-loader in the module settings of webpack,then you can use ES6+ to write your web program.
Omi did not abandon the ES5 users, you can also use ES5 to write Omi.[Try Omi-ES5 on Playground]
License
This content is released under the MIT License.