How to use vux uploader image upload component
This time I will show you how to use the vux uploader image upload component. What are the precautions when using the vux uploader image upload component. The following is a practical case, let's take a look.
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 image 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: carry parameter
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 capture Attribute
Note: It can be set to camera. Click the Add button at this time. Some models will directly activate 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 analysis of the WeChat applet entry tutorial case
How to use the http server in angularjs
The above is the detailed content of How to use vux uploader image upload component. 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

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

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



With the continuous development of social media, Xiaohongshu has become a platform for more and more young people to share their lives and discover beautiful things. Many users are troubled by auto-save issues when posting images. So, how to solve this problem? 1. How to solve the problem of automatically saving pictures when publishing on Xiaohongshu? 1. Clear the cache First, we can try to clear the cache data of Xiaohongshu. The steps are as follows: (1) Open Xiaohongshu and click the "My" button in the lower right corner; (2) On the personal center page, find "Settings" and click it; (3) Scroll down and find the "Clear Cache" option. Click OK. After clearing the cache, re-enter Xiaohongshu and try to post pictures to see if the automatic saving problem is solved. 2. Update the Xiaohongshu version to ensure that your Xiaohongshu

With the popularity of Douyin short videos, user interactions in the comment area have become more colorful. Some users wish to share images in comments to better express their opinions or emotions. So, how to post pictures in TikTok comments? This article will answer this question in detail and provide you with some related tips and precautions. 1. How to post pictures in Douyin comments? 1. Open Douyin: First, you need to open Douyin APP and log in to your account. 2. Find the comment area: When browsing or posting a short video, find the place where you want to comment and click the "Comment" button. 3. Enter your comment content: Enter your comment content in the comment area. 4. Choose to send a picture: In the interface for entering comment content, you will see a "picture" button or a "+" button, click

Apple's recent iPhones capture memories with crisp detail, saturation and brightness. But sometimes, you may encounter some issues that may cause the image to look less clear. While autofocus on iPhone cameras has come a long way, allowing you to take photos quickly, the camera can mistakenly focus on the wrong subject in certain situations, making the photo blurry in unwanted areas. If your photos on your iPhone look out of focus or lack sharpness overall, the following post should help you make them sharper. How to Make Pictures Clearer on iPhone [6 Methods] You can try using the native Photos app to clean up your photos. If you want more features and options

In PowerPoint, it is a common technique to display pictures one by one, which can be achieved by setting animation effects. This guide details the steps to implement this technique, including basic setup, image insertion, adding animation, and adjusting animation order and timing. Additionally, advanced settings and adjustments are provided, such as using triggers, adjusting animation speed and order, and previewing animation effects. By following these steps and tips, users can easily set up pictures to appear one after another in PowerPoint, thereby enhancing the visual impact of the presentation and grabbing the attention of the audience.

Some netizens found that when they opened the browser web page, the pictures on the web page could not be loaded for a long time. What happened? I checked that the network is normal, so where is the problem? The editor below will introduce to you six solutions to the problem that web page images cannot be loaded. Web page images cannot be loaded: 1. Internet speed problem The web page cannot display images. It may be because the computer's Internet speed is relatively slow and there are more softwares opened on the computer. And the images we access are relatively large, which may be due to loading timeout. As a result, the picture cannot be displayed. You can turn off the software that consumes more network speed. You can go to the task manager to check. 2. Too many visitors. If the webpage cannot display pictures, it may be because the webpages we visited were visited at the same time.

Are you also using Foxit PDF Reader software? So do you know how Foxit PDF Reader converts pdf documents into jpg images? The following article brings you how Foxit PDF Reader converts pdf documents into jpg images. For those who are interested in the method of converting jpg images, please come and take a look below. First start Foxit PDF Reader, then find "Features" on the top toolbar, and then select the "PDF to Others" function. Next, open a web page called "Foxit PDF Online Conversion". Click the "Login" button on the upper right side of the page to log in, and then turn on the "PDF to Image" function. Then click the upload button and add the pdf file you want to convert into an image. After adding it, click "Start Conversion"

Overview of advanced functions of how to use HTML, CSS and jQuery to implement image merge display: In web design, image display is an important link, and image merge display is one of the common techniques to improve page loading speed and enhance user experience. This article will introduce how to use HTML, CSS and jQuery to implement advanced functions of image merging and display, and provide specific code examples. 1. HTML layout: First, we need to create a container in HTML to display the merged images. You can use di

How to use JavaScript to implement the drag and zoom function of images? In modern web development, dragging and zooming images is a common requirement. By using JavaScript, we can easily add dragging and zooming functions to images to provide a better user experience. In this article, we will introduce how to use JavaScript to implement this function, with specific code examples. HTML structure First, we need a basic HTML structure to display pictures and add
