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

请问支持react function component 吗? #10

Open
chenzp1996 opened this issue Feb 27, 2022 · 0 comments
Open

请问支持react function component 吗? #10

chenzp1996 opened this issue Feb 27, 2022 · 0 comments

Comments

@chenzp1996
Copy link

chenzp1996 commented Feb 27, 2022

我用下面这个demo,组件里定义方法funA,但是却得到methods:[],请问是不支持fc还是我写法有问题?麻烦看看,谢谢🙏

import React from 'react';
import PropTypes from 'prop-types';

/**
 * 人物组件
 * @description 公共banner组件
 */
const Banner = (props) => {
    const {src} = props;

    Banner.propTypes = {
        /**
         * banner图片地址
         */
        src: PropTypes.string.isRequired
    };

    Banner.defaultProps = {
        src: ''
    };

    /**
     * 这是方法funA,它没出现在解析后的methods中
     * @param {String} text 文本内容
     */
    const funA = (text) => {
        console.log(text);
    };

    return (
        <div>
            <img src={src} />
        </div>
    );
};

export default Banner;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant