antd-mobile-taro-ui
Version:
以antd-mobile为设计标准,基于taro框架的微信小程序组件库
34 lines • 1.21 kB
JavaScript
import React from 'react';
import classNames from 'classnames';
import { BackIcon } from 'antd-mobile-taro-icons';
import { withNativeProps } from 'antd-mobile/es/utils/native-props';
import { mergeProps } from 'antd-mobile/es/utils/with-default-props';
import { View } from '@tarojs/components';
const classPrefix = `adm-nav-bar`;
const defaultProps = {
back: '',
backArrow: true
};
export const NavBar = p => {
const props = mergeProps(defaultProps, p);
const {
back,
backArrow
} = props;
return withNativeProps(props, React.createElement(View, {
className: classNames(classPrefix)
}, React.createElement(View, {
className: `${classPrefix}-left`
}, back !== null && React.createElement(View, {
className: `${classPrefix}-back`,
onClick: props.onBack
}, backArrow && React.createElement(View, {
className: `${classPrefix}-back-arrow`
}, backArrow === true ? React.createElement(BackIcon, null) : backArrow), React.createElement(View, {
"aria-hidden": 'true'
}, back)), props.left), React.createElement(View, {
className: `${classPrefix}-title`
}, props.children), React.createElement(View, {
className: `${classPrefix}-right`
}, props.right)));
};