Comprehensive set of built-in Vue components optimized for cross-platform development. These components provide native-like functionality across different platforms while maintaining consistent APIs and styling.
Core interface elements for displaying content and basic user interactions.
/**
* Button component for user interactions
*/
export const Button: DefineComponent<{
size?: 'default' | 'mini';
type?: 'primary' | 'default' | 'warn';
plain?: boolean;
disabled?: boolean;
loading?: boolean;
formType?: 'submit' | 'reset';
openType?: 'contact' | 'share' | 'getUserInfo' | 'getPhoneNumber' | 'launchApp' | 'openSetting' | 'feedback';
hoverClass?: string;
hoverStopPropagation?: boolean;
hoverStartTime?: number;
hoverStayTime?: number;
// Event handlers
onTap?: (event: any) => void;
onGetUserInfo?: (event: any) => void;
onGetPhoneNumber?: (event: any) => void;
}>;
/**
* Basic view container component
*/
export const View: DefineComponent<{
hoverClass?: string;
hoverStopPropagation?: boolean;
hoverStartTime?: number;
hoverStayTime?: number;
// Event handlers
onTap?: (event: any) => void;
}>;
/**
* Text display component
*/
export const Text: DefineComponent<{
selectable?: boolean;
space?: 'ensp' | 'emsp' | 'nbsp';
decode?: boolean;
}>;
/**
* Image display component
*/
export const Image: DefineComponent<{
src: string;
mode?: 'scaleToFill' | 'aspectFit' | 'aspectFill' | 'widthFix' | 'heightFix' | 'top' | 'bottom' | 'center' | 'left' | 'right' | 'top left' | 'top right' | 'bottom left' | 'bottom right';
webp?: boolean;
lazyLoad?: boolean;
fadeShow?: boolean;
// Event handlers
onLoad?: (event: any) => void;
onError?: (event: any) => void;
}>;
/**
* Icon display component
*/
export const Icon: DefineComponent<{
type: string;
size?: number | string;
color?: string;
}>;
/**
* Rich text display component
*/
export const RichText: DefineComponent<{
nodes: string | any[];
space?: 'ensp' | 'emsp' | 'nbsp';
}>;Usage Examples:
import { Button, View, Text, Image } from "@dcloudio/uni-h5";
// Basic button usage
<Button type="primary" @tap="handleClick">Click Me</Button>
// Container with text
<View class="container">
<Text>Hello UniApp H5</Text>
<Image src="/path/to/image.jpg" mode="aspectFit" @load="onImageLoad" />
</View>Input controls and form elements for data collection and user input.
/**
* Form container component
*/
export const Form: DefineComponent<{
reportSubmit?: boolean;
reportSubmitTimeout?: number;
// Event handlers
onSubmit?: (event: any) => void;
onReset?: (event: any) => void;
}>;
/**
* Text input component
*/
export const Input: DefineComponent<{
value?: string;
type?: 'text' | 'number' | 'idcard' | 'digit' | 'safe-password' | 'nickname';
password?: boolean;
placeholder?: string;
placeholderStyle?: string;
placeholderClass?: string;
disabled?: boolean;
maxlength?: number;
cursor?: number;
focus?: boolean;
confirmType?: 'send' | 'search' | 'next' | 'go' | 'done';
confirmHold?: boolean;
cursor?: number;
selectionStart?: number;
selectionEnd?: number;
adjustPosition?: boolean;
autoBlur?: boolean;
ignoreCompositionEvent?: boolean;
// Event handlers
onInput?: (event: any) => void;
onFocus?: (event: any) => void;
onBlur?: (event: any) => void;
onConfirm?: (event: any) => void;
onKeyboardHeightChange?: (event: any) => void;
}>;
/**
* Multi-line text input component
*/
export const Textarea: DefineComponent<{
value?: string;
placeholder?: string;
placeholderStyle?: string;
placeholderClass?: string;
disabled?: boolean;
maxlength?: number;
focus?: boolean;
autoHeight?: boolean;
fixed?: boolean;
cursorSpacing?: number;
cursor?: number;
showConfirmBar?: boolean;
selectionStart?: number;
selectionEnd?: number;
adjustPosition?: boolean;
disableDefaultPadding?: boolean;
// Event handlers
onInput?: (event: any) => void;
onFocus?: (event: any) => void;
onBlur?: (event: any) => void;
onConfirm?: (event: any) => void;
onLineChange?: (event: any) => void;
onKeyboardHeightChange?: (event: any) => void;
}>;
/**
* Checkbox input component
*/
export const Checkbox: DefineComponent<{
value?: string;
disabled?: boolean;
checked?: boolean;
color?: string;
// Event handlers
onChange?: (event: any) => void;
}>;
/**
* Checkbox group container
*/
export const CheckboxGroup: DefineComponent<{
// Event handlers
onChange?: (event: any) => void;
}>;
/**
* Radio button component
*/
export const Radio: DefineComponent<{
value?: string;
checked?: boolean;
disabled?: boolean;
color?: string;
// Event handlers
onChange?: (event: any) => void;
}>;
/**
* Radio button group container
*/
export const RadioGroup: DefineComponent<{
// Event handlers
onChange?: (event: any) => void;
}>;
/**
* Toggle switch component
*/
export const Switch: DefineComponent<{
checked?: boolean;
disabled?: boolean;
type?: 'switch' | 'checkbox';
color?: string;
// Event handlers
onChange?: (event: any) => void;
}>;
/**
* Slider input component
*/
export const Slider: DefineComponent<{
min?: number;
max?: number;
step?: number;
disabled?: boolean;
value?: number;
color?: string;
selectedColor?: string;
activeColor?: string;
backgroundColor?: string;
blockSize?: number;
blockColor?: string;
showValue?: boolean;
// Event handlers
onChange?: (event: any) => void;
onChanging?: (event: any) => void;
}>;
/**
* Form label component
*/
export const Label: DefineComponent<{
for?: string;
}>;Usage Examples:
import { Form, Input, Textarea, Checkbox, CheckboxGroup, Radio, RadioGroup, Switch } from "@dcloudio/uni-h5";
// Form with various inputs
<Form @submit="onSubmit">
<Input
v-model="formData.name"
placeholder="Enter your name"
@input="onInputChange"
/>
<Textarea
v-model="formData.description"
placeholder="Enter description"
auto-height
/>
<CheckboxGroup @change="onCheckboxChange">
<Checkbox value="option1">Option 1</Checkbox>
<Checkbox value="option2">Option 2</Checkbox>
</CheckboxGroup>
<RadioGroup @change="onRadioChange">
<Radio value="choice1">Choice 1</Radio>
<Radio value="choice2">Choice 2</Radio>
</RadioGroup>
<Switch v-model="formData.enabled" @change="onSwitchChange" />
</Form>Components for organizing content layout and providing navigation functionality.
/**
* Scrollable container component
*/
export const ScrollView: DefineComponent<{
scrollX?: boolean;
scrollY?: boolean;
upperThreshold?: number;
lowerThreshold?: number;
scrollTop?: number;
scrollLeft?: number;
scrollIntoView?: string;
scrollWithAnimation?: boolean;
enableBackToTop?: boolean;
enableFlexScroll?: boolean;
scrollAnchoring?: boolean;
refresherEnabled?: boolean;
refresherThreshold?: number;
refresherDefaultStyle?: string;
refresherBackground?: string;
refresherTriggered?: boolean;
// Event handlers
onScrollToUpper?: (event: any) => void;
onScrollToLower?: (event: any) => void;
onScroll?: (event: any) => void;
onRefresherPulling?: (event: any) => void;
onRefresherRefresh?: (event: any) => void;
onRefresherRestore?: (event: any) => void;
onRefresherAbort?: (event: any) => void;
}>;
/**
* Swiper/carousel component
*/
export const Swiper: DefineComponent<{
indicatorDots?: boolean;
indicatorColor?: string;
indicatorActiveColor?: string;
autoplay?: boolean;
current?: number;
currentItemId?: string;
interval?: number;
duration?: number;
circular?: boolean;
vertical?: boolean;
previousMargin?: string;
nextMargin?: string;
displayMultipleItems?: number;
skipHiddenItemLayout?: boolean;
easingFunction?: string;
// Event handlers
onChange?: (event: any) => void;
onTransition?: (event: any) => void;
onAnimationFinish?: (event: any) => void;
}>;
/**
* Individual swiper slide component
*/
export const SwiperItem: DefineComponent<{
itemId?: string;
}>;
/**
* Navigation link component
*/
export const Navigator: DefineComponent<{
target?: 'self' | 'miniProgram';
url?: string;
openType?: 'navigate' | 'redirect' | 'switchTab' | 'reLaunch' | 'navigateBack';
delta?: number;
appId?: string;
path?: string;
extraData?: any;
version?: 'develop' | 'trial' | 'release';
hoverClass?: string;
hoverStopPropagation?: boolean;
hoverStartTime?: number;
hoverStayTime?: number;
// Event handlers
onSuccess?: (event: any) => void;
onFail?: (event: any) => void;
onComplete?: (event: any) => void;
}>;
/**
* Movable container area
*/
export const MovableArea: DefineComponent<{
scaleArea?: boolean;
}>;
/**
* Movable view element
*/
export const MovableView: DefineComponent<{
direction?: 'all' | 'vertical' | 'horizontal' | 'none';
inertia?: boolean;
outOfBounds?: boolean;
x?: number;
y?: number;
damping?: number;
friction?: number;
disabled?: boolean;
scale?: boolean;
scaleMin?: number;
scaleMax?: number;
scaleValue?: number;
animation?: boolean;
// Event handlers
onChange?: (event: any) => void;
onScale?: (event: any) => void;
}>;Components for media display, editing, and advanced user interactions.
/**
* Canvas drawing component
*/
export const Canvas: DefineComponent<{
canvasId: string;
disableScroll?: boolean;
hidpi?: boolean;
type?: '2d' | 'webgl';
// Event handlers
onTouchStart?: (event: any) => void;
onTouchMove?: (event: any) => void;
onTouchEnd?: (event: any) => void;
onTouchCancel?: (event: any) => void;
onLongTap?: (event: any) => void;
onError?: (event: any) => void;
}>;
/**
* Rich text editor component
*/
export const Editor: DefineComponent<{
readOnly?: boolean;
placeholder?: string;
showImgSize?: boolean;
showImgToolbar?: boolean;
showImgResize?: boolean;
// Event handlers
onReady?: (event: any) => void;
onFocus?: (event: any) => void;
onBlur?: (event: any) => void;
onInput?: (event: any) => void;
onStatusChange?: (event: any) => void;
}>;
/**
* Progress indicator component
*/
export const Progress: DefineComponent<{
percent?: number;
showInfo?: boolean;
borderRadius?: number;
fontSize?: number;
strokeWidth?: number;
color?: string;
activeColor?: string;
backgroundColor?: string;
active?: boolean;
activeMode?: 'backwards' | 'forwards';
duration?: number;
}>;
/**
* Resize detection component
*/
export const ResizeSensor: DefineComponent<{
// Event handlers
onResize?: (event: any) => void;
}>;
/**
* Picker view component
*/
export const PickerView: DefineComponent<{
value?: number[];
indicatorStyle?: string;
indicatorClass?: string;
maskStyle?: string;
maskClass?: string;
// Event handlers
onChange?: (event: any) => void;
onPickStart?: (event: any) => void;
onPickEnd?: (event: any) => void;
}>;
/**
* Picker column component
*/
export const PickerViewColumn: DefineComponent<{}>;Extended components available in the X platform build for enhanced functionality.
/**
* List view component (X platform only)
*/
export const ListView: DefineComponent<{
// X platform specific props
}>;
/**
* List item component (X platform only)
*/
export const ListItem: DefineComponent<{
// X platform specific props
}>;
/**
* Sticky section component (X platform only)
*/
export const StickySection: DefineComponent<{
// X platform specific props
}>;
/**
* Sticky header component (X platform only)
*/
export const StickyHeader: DefineComponent<{
// X platform specific props
}>;Extended components for specialized use cases and media handling.
/**
* Video player component
*/
export const Video: DefineComponent<{
src: string;
duration?: number;
controls?: boolean;
danmuList?: any[];
danmuBtn?: boolean;
enableDanmu?: boolean;
autoplay?: boolean;
loop?: boolean;
muted?: boolean;
initialTime?: number;
direction?: number;
showProgress?: boolean;
showFullscreenBtn?: boolean;
showPlayBtn?: boolean;
showCenterPlayBtn?: boolean;
enableProgressGesture?: boolean;
objectFit?: 'contain' | 'fill' | 'cover';
poster?: string;
showMuteBtn?: boolean;
title?: string;
playBtnPosition?: 'bottom' | 'center';
enablePlayGesture?: boolean;
autoPauseIfNavigate?: boolean;
autoPauseIfOpenNative?: boolean;
vslideGesture?: boolean;
vslideGestureInFullscreen?: boolean;
adUnitId?: string;
posterForCrawler?: string;
codecCache?: number;
httpCache?: boolean;
playStrategy?: number;
header?: Record<string, any>;
// Event handlers
onPlay?: (event: any) => void;
onPause?: (event: any) => void;
onEnded?: (event: any) => void;
onTimeUpdate?: (event: any) => void;
onFullscreenChange?: (event: any) => void;
onWaiting?: (event: any) => void;
onError?: (event: any) => void;
onProgress?: (event: any) => void;
onLoadedMetadata?: (event: any) => void;
onControlsToggle?: (event: any) => void;
onEnterPictureInPicture?: (event: any) => void;
onLeavePictureInPicture?: (event: any) => void;
onSeekComplete?: (event: any) => void;
}>;
/**
* Web view component
*/
export const WebView: DefineComponent<{
src: string;
allowFullscreen?: boolean;
// Event handlers
onMessage?: (event: any) => void;
onLoad?: (event: any) => void;
onError?: (event: any) => void;
}>;
/**
* Map display component
*/
export const Map: DefineComponent<{
longitude: number;
latitude: number;
scale?: number;
markers?: any[];
covers?: any[];
polyline?: any[];
circles?: any[];
controls?: any[];
includePoints?: any[];
showLocation?: boolean;
polygons?: any[];
subkey?: string;
layerStyle?: number;
rotate?: number;
skew?: number;
enable3D?: boolean;
showCompass?: boolean;
showScale?: boolean;
enableOverlooking?: boolean;
enableZoom?: boolean;
enableScroll?: boolean;
enableRotate?: boolean;
enableSatellite?: boolean;
enableTraffic?: boolean;
enablePoi?: boolean;
enableBuilding?: boolean;
setting?: any;
// Event handlers
onTap?: (event: any) => void;
onMarkerTap?: (event: any) => void;
onLabelTap?: (event: any) => void;
onControlTap?: (event: any) => void;
onCalloutTap?: (event: any) => void;
onUpdated?: (event: any) => void;
onRegionChange?: (event: any) => void;
onPoiTap?: (event: any) => void;
onAnchorPointTap?: (event: any) => void;
}>;// Common event types
interface TapEvent {
type: 'tap';
timeStamp: number;
target: EventTarget;
currentTarget: EventTarget;
detail: {
x: number;
y: number;
};
}
interface InputEvent {
type: 'input';
target: EventTarget;
currentTarget: EventTarget;
detail: {
value: string;
cursor?: number;
keyCode?: number;
};
}
interface ChangeEvent {
type: 'change';
target: EventTarget;
currentTarget: EventTarget;
detail: {
value: any;
};
}
// Component specific interfaces
interface EventTarget {
id: string;
offsetLeft: number;
offsetTop: number;
dataset: Record<string, any>;
}