np-upload Upload

A wrapper around n-upload that provides two-way binding of the file list via v-model.

The v-model value is of type string[], where each item is a JSON string of {name, url, type} by default. When listType is image-card and urlOnly is true, each item only stores the file's url string.

Basic Usage

Bind the file list with v-model and pass n-upload props through props.

浏览器不支持,请手动复制 basic.en.vue

Custom Upload Area

Customize the trigger area through the default slot, e.g. to implement image card upload with listType: 'image-card'.

浏览器不支持,请手动复制 custom.en.vue

urlOnly Mode

When listType is image-card, set urlOnly to true and the v-model value will be simplified to an array of url strings.

浏览器不支持,请手动复制 url-only.en.vue

Component Configuration

Props

PropDescriptionTypeDefault
v-modelFile list, each item is a JSON string of {name, url, type}; in urlOnly mode, each item is a url stringstring[][]
urlOnlyOnly effective when listType: 'image-card', v-model value is simplified to an array of url stringsbooleanfalse
propsNUpload propsNUpload Propsopen in new window-
onChangeFile list change event, first argument is the v-model value, second is the actual fileList(value: string[], fileList: UploadFileInfo[]) => void-

Slots

SlotDescription
defaultUpload trigger area content

Types

The component exports the following type definitions:

import type { NpUploadProps } from 'naive-plus'