vux uploader image upload component usage tutorial
This time I will bring you a tutorial on how to use the vux uploader image upload component. What are the precautions when using the vux uploader image upload component? Here are practical cases, let’s take a look.
1. Website: https://github.com/greedying/vux-uploader
2. Installation
npm install vux-uploader --save npm install --save-dev babel-preset-es2015 .babelrc { "presets": [ ["env", { "modules": false, "targets": { "browsers": ["> 1%", "last 2 versions", "not ie <= 8"] } }], "es2015", "stage-2" ], "plugins": ["transform-runtime"], "env": { "test": { "presets": ["env", "es2015", "stage-2"], "plugins": ["istanbul"] } } }
3. Use
// 引入组件 import Uploader from 'vux-uploader' // 子组件 export default { ... components: { ... Uploader, ... } ... } // 使用组件 <uploader :max="varmax" :images="images" :handle-click="true" :show-header="false" :readonly="true" :upload-url="uploadUrl" name="img" :params="params" size="small" @preview="previewMethod" @add-image="addImageMethod" @remove-image="removeImageMethod" ></uploader>
Parameter description:
images
Type: Array
Default value: [], empty array
Meaning: Image array, the format is [ { url: '/url/of/img.ong' }, ...]
Note: When the variable is an array, the data flow is bidirectional. Changing the value of the array within the component affects the parent component
max
Type: Number
Default value: 1
Meaning : Maximum number of pictures
Remarks: When the picture reaches the max value, the new button disappears
showHeader
Type: Boolean
Default value: true
Meaning: Whether to display the header
Remarks : Control the display of the entire header
title
Type: String
Default value: Image upload
Meaning: Title of the header
Remarks: Leave blank if not displayed
showTip
Type: Boolean
Default value: true
Meaning: Whether to display the digital part of the header, that is, the 1/3 part
Note: When showHeader is false, the header is hidden as a whole, and this parameter is invalid
readonly
Type: Boolean
Default value: false
Meaning: Whether to read-only
Note: When read-only, the add and delete buttons are hidden
handleClick
Type: Boolean
Default value: false
Meaning: Whether to take over the click event of the new button. If so, clicking the new button will no longer automatically appear the image selection interface
Note: When true, click the new button, then $emit( 'add-image'), you can perform customized operations such as selecting images within this event. After that, the addition, uploading, and deletion of images are taken over by the user
autoUpload
Type: Boolean
Default value : true
Meaning: Whether to automatically upload the picture after selecting it. If yes, the internal upload interface is called. No, then $emit('upload-image', formData)',formData` is the image content, and the user can listen to the event and upload it himself
Note: When handleClick is true, image selection cannot be performed, so this parameter is invalid. When this parameter is false, after selecting the image, $emit('upload-image', formData)', formData` is the image content
uploadUrl
Type: String
Default value: ''
Meaning : Receive the url of the uploaded image
Note: You need to return the json string in the following format, otherwise please set autoUpload to false and upload it yourself
{
Result: 0,
message: "Error message when result is not 0",
data: {
url: "http://image.url.com/image.png"
}
}
name
Type: String
Default value: img
Meaning: When uploading by default, the form name
used for images Remarks: None
params
Type: Object
Default value: null
Meaning: Parameter
is carried when uploading files Remarks: None
size
Type: String
Default value: normal
Meaning: Size type
Remarks: normal is the default size of weui, small is the smaller size defined by the author
capture
Type: String
Default value: ''
Meaning: input's capture attribute
Remarks: Can be set to camera, click the Add button at this time, and some models will directly bring up the camera. Note that the performance of each model of mobile phone is different, so please use it with caution. When handleClick is true, this attribute is invalid
emit event description
add-image
Emit timing: When the handleClick parameter is true, click the new button
Parameters: None
Remarks: None
remove-image
Emit timing: When the handleClick parameter is true, click the delete button
Parameters: None
Note: When handleClick is false, click the delete button and the first image is deleted inside the component; Otherwise, the user needs to listen to this event and perform the corresponding deletion operation
preview
Emit timing: When clicking any picture
Parameters: Picture object, the format is { url: 'imgUrl' }
Note: The automatic preview function has not been implemented for the time being. If users need to monitor events, they can implement it themselves
upload-image
emit timing: When both handleClick and autoUpload are false`, select the image
Parameters: formData, generated from the image content formData
Note: You can get the input element of the image through vm.$refs.input
I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to other related articles on the PHP Chinese website !
Recommended reading:
Detailed explanation of how to use the $http service in AngularJS
vue addRoutes Detailed explanation of the steps to implement dynamic permission routing menu
The above is the detailed content of vux uploader image upload component usage tutorial. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



Magnet link is a link method for downloading resources, which is more convenient and efficient than traditional download methods. Magnet links allow you to download resources in a peer-to-peer manner without relying on an intermediary server. This article will introduce how to use magnet links and what to pay attention to. 1. What is a magnet link? A magnet link is a download method based on the P2P (Peer-to-Peer) protocol. Through magnet links, users can directly connect to the publisher of the resource to complete resource sharing and downloading. Compared with traditional downloading methods, magnetic

How to use mdf files and mds files With the continuous advancement of computer technology, we can store and share data in a variety of ways. In the field of digital media, we often encounter some special file formats. In this article, we will discuss a common file format - mdf and mds files, and introduce how to use them. First, we need to understand the meaning of mdf files and mds files. mdf is the extension of the CD/DVD image file, and the mds file is the metadata file of the mdf file.

CrystalDiskMark is a small HDD benchmark tool for hard drives that quickly measures sequential and random read/write speeds. Next, let the editor introduce CrystalDiskMark to you and how to use crystaldiskmark~ 1. Introduction to CrystalDiskMark CrystalDiskMark is a widely used disk performance testing tool used to evaluate the read and write speed and performance of mechanical hard drives and solid-state drives (SSD). Random I/O performance. It is a free Windows application and provides a user-friendly interface and various test modes to evaluate different aspects of hard drive performance and is widely used in hardware reviews

foobar2000 is a software that can listen to music resources at any time. It brings you all kinds of music with lossless sound quality. The enhanced version of the music player allows you to get a more comprehensive and comfortable music experience. Its design concept is to play the advanced audio on the computer The device is transplanted to mobile phones to provide a more convenient and efficient music playback experience. The interface design is simple, clear and easy to use. It adopts a minimalist design style without too many decorations and cumbersome operations to get started quickly. It also supports a variety of skins and Theme, personalize settings according to your own preferences, and create an exclusive music player that supports the playback of multiple audio formats. It also supports the audio gain function to adjust the volume according to your own hearing conditions to avoid hearing damage caused by excessive volume. Next, let me help you

Many users always encounter some problems when playing some games on win10, such as screen freezes and blurred screens. At this time, we can solve the problem by turning on the directplay function, and the operation method of the function is also Very simple. How to install directplay, the old component of win10 1. Enter "Control Panel" in the search box and open it 2. Select large icons as the viewing method 3. Find "Programs and Features" 4. Click on the left to enable or turn off win functions 5. Select the old version here Just check the box

NetEase Mailbox, as an email address widely used by Chinese netizens, has always won the trust of users with its stable and efficient services. NetEase Mailbox Master is an email software specially created for mobile phone users. It greatly simplifies the process of sending and receiving emails and makes our email processing more convenient. So how to use NetEase Mailbox Master, and what specific functions it has. Below, the editor of this site will give you a detailed introduction, hoping to help you! First, you can search and download the NetEase Mailbox Master app in the mobile app store. Search for "NetEase Mailbox Master" in App Store or Baidu Mobile Assistant, and then follow the prompts to install it. After the download and installation is completed, we open the NetEase email account and log in. The login interface is as shown below

Cloud storage has become an indispensable part of our daily life and work nowadays. As one of the leading cloud storage services in China, Baidu Netdisk has won the favor of a large number of users with its powerful storage functions, efficient transmission speed and convenient operation experience. And whether you want to back up important files, share information, watch videos online, or listen to music, Baidu Cloud Disk can meet your needs. However, many users may not understand the specific use method of Baidu Netdisk app, so this tutorial will introduce in detail how to use Baidu Netdisk app. Users who are still confused can follow this article to learn more. ! How to use Baidu Cloud Network Disk: 1. Installation First, when downloading and installing Baidu Cloud software, please select the custom installation option.

MetaMask (also called Little Fox Wallet in Chinese) is a free and well-received encryption wallet software. Currently, BTCC supports binding to the MetaMask wallet. After binding, you can use the MetaMask wallet to quickly log in, store value, buy coins, etc., and you can also get 20 USDT trial bonus for the first time binding. In the BTCCMetaMask wallet tutorial, we will introduce in detail how to register and use MetaMask, and how to bind and use the Little Fox wallet in BTCC. What is MetaMask wallet? With over 30 million users, MetaMask Little Fox Wallet is one of the most popular cryptocurrency wallets today. It is free to use and can be installed on the network as an extension
