Coder Social home page Coder Social logo

文档 - 开发指南 about element-react HOT 1 CLOSED

elemefe avatar elemefe commented on May 21, 2024
文档 - 开发指南

from element-react.

Comments (1)

e1emeb0t avatar e1emeb0t commented on May 21, 2024

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

from element-react.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.