Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

文档 - 开发指南 #41

Closed
rlog opened this issue Oct 26, 2016 · 1 comment
Closed

文档 - 开发指南 #41

rlog opened this issue Oct 26, 2016 · 1 comment
Milestone

Comments

@rlog
Copy link
Contributor

rlog commented Oct 26, 2016

No description provided.

@rlog rlog modified the milestone: v1.0.0 Oct 26, 2016
@e1emeb0t
Copy link
Contributor

以Alert为例,

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的默认页面
    };
  }
}

@ElemeFE ElemeFE locked and limited conversation to collaborators Apr 21, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants