Comments (1)
以Alert为例,
- 参照
element-ui
的样式和方法, http://element.eleme.io/#/component/alert - 找到
el-alert
的源代码, https://github.com/ElemeFE/element/tree/master/packages/alert/src - 在项目的
src
目录下创建alert目录, 同时创建入口文件index.js
. - 注册组件Alert, 编辑
src/index.js
,
export { default as Alert } from './alert'; // 注册Alert组件
- 初始化
src/alert/index.js
, 参照element-ui
下的packages/alert/src/main.vue
,
import React, { PropTypes } from 'react';
import { Component, View } from '../../libs';
export default class Alert extends Component {
render() {
// el-alert的<template />
}
}
Alert.propTypes = {
// el-alert的props.type
}
Alert.defaultProps = {
// el-alert的props.default
};
- 在项目的
demo/pages
目录下创建alert目录, 同时创建index.js
, 或者style.scss
.
import './style.scss';
import React from 'react';
import { Alert } from '../../../src';
export default class Playground extends React.Component {
render() {
return (
<div>
<section className="demo-section">
<div className="demo-header">
<h2>Alert 警告</h2>
<p>用于页面中展示重要的提示信息。</p>
<h3>基本用法</h3>
<p>页面中的非浮层元素,不会自动消失。</p>
</div>
<div className="demo-content demo-alert">
<Alert title="成功提示的文案" type="success" />
<Alert title="消息提示的文案" type="info" />
<Alert title="警告提示的文案" type="warning" />
<Alert title="错误提示的文案" type="error" />
</div>
</section>
</div>
)
}
}
.demo-alert {
.el-alert {
margin-bottom: 20px;
}
}
- 编辑
demo/pages/index.js
, 注册Alert, 设置Demo的默认页.
import Alert from './alert';
// pages是有序的Object, 会影响到左侧的菜单顺序.
const pages = {
alert: { title: 'Alert 警告', component: Alert },
};
class App extends React.Component {
constructor(props) {
super(props);
this.state = {
page: 'alert' // Demo的默认页面
};
}
}
from element-react.
Related Issues (20)
- Pagination: quick next button is wrongly positioned
- Place footer below header of table
- Is this project deprecated ? [question] HOT 1
- Disable onRowClick for one column of row HOT 1
- Form 的 resetFields方法无效 HOT 1
- Table No Data text is not editable HOT 4
- gitter & discord HOT 1
- element-china-area-data 数据中**省-台中市,后面对应的code错误
- Radio.Group组件在苹果手机上需要双击才会实现radio功能,单击会选中单击的,之前选中的没有取消选中
- Tree的checkbox为什么不支持禁用disabled
- 走马灯样式丢失
- DatePicker bug
- table 如何合并单元格?? HOT 1
- Component中添加第二个Tree组件后报错
- el-table-column中formatter函数渲染多次
- 什么时候出ts版本 HOT 1
- tree业务场景太少了
- 颜色选择器如果存于一个FORM里时 点击确定按钮会自动提交FORM
- 一使用就报各种依赖找不到,难道要一个个的手动安装?垃圾
- 只有我一个人遇到了没有与此匹配的重载这个问题吗?
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from element-react.