
Product
Introducing Repository Access Permissions and Custom Roles
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.
vux-upload-component
Advanced tools
vux-upload-component是一个vue的上传组件,是对vux组件库的一个补充。 因为vux并没有对weui的uploader组件进行封装,理由见vux issue 682,但这又是一个常见需求。在使用vux过程中,实现了这个组件,现整理开源出来,命名为vux-upload-component。
$t方式的多语言功能vux2的项目babel对ES6部分语法进行转码less-loader正确编译less源码webpack的方式,暂不提供umd版vux-upload-componentnpm install vux-upload-component --save
vux-upload-component// 引入组件
import Uploader from 'vux-upload-component'
// 子组件
export default {
...
components: {
...
Uploader,
...
}
...
}
// 使用组件
<uploader
:max="varmax"
:images="images"
:handle-click="true"
:show-header="false"
:readonly="true"
:upload-url="uploadUrl"
:upload-headers="uploadHeaders
name="img"
:params="params"
size="small"
@preview="previewMethod"
@add-image="addImageMethod"
@remove-image="removeImageMethod"
></uploader>
images
类型: Array默认值: [],空数组含义: 图片数组,格式为 [ { url: '/url/of/img.ong' }, ...]备注: 变量为数组时,数据流为双向,在组件内部改变数组的值影响父组件max
类型: Number默认值: 1含义: 图片最大张数备注: 图片达到max值时,新增按钮消失showHeader
类型: Boolean默认值: true含义: 是否显示头部备注: 控制整个头部的显示title
类型: String默认值: 图片上传含义: 头部的标题备注: 不显示则留空showTip
类型: Boolean默认值: true含义: 是否显示头部数字部分,即1/3部分备注: 当showHeader为false时,header整体隐藏,此时本参数无效readonly
类型: Boolean默认值: false含义: 是否只读备注: 只读时,新增和删除按钮隐藏handleClick
类型: Boolean默认值: false含义: 是否接管新增按钮的点击事件,如果是,点击新增按钮不再自动出现选择图片界面备注: true时,点击新增按钮,则$emit('add-image'),可以在此事件内进行自定义的选择图片等操作,此后图片的新增、上传、删除都由使用者接管autoUpload
类型: Boolean默认值: true含义: 选择图片后是否自动上传。是,则调用内部上传接口。否,则$emit('upload-image', formData)', formData`为图片内容,用户可监听事件自己上传备注: handleClick为true时,无法进行图片选择,故此参数无效。此参数为false时,选择图片后,$emit('upload-image', formData)', formData`为图片内容uploadUrl
类型: String默认值: ''含义: 接收上传图片的url备注: 需要返回如下格式的json字符串,否则请设置autoUpload为false自行上传uploadHeaders
类型: Object默认值: {}含义: 接收上传图片的请求头response headers备注: 默认使用axios的请求头默认设置 {
result: 0,
message: "result不是0时候的错误信息",
data: {
url: "http://image.url.com/image.png"
}
}
name
类型: String默认值: img含义: 默认上传的时候,图片使用的表单name备注: 无params
类型: Object默认值: null含义: 上传文件时携带参数备注: 无size
类型: String默认值: normal含义: 尺寸类型备注: normal为weui默认尺寸,small为作者定义的小一些的尺寸capture
类型: String默认值: ''含义: input 的capture属性备注: 可以设置为camera,此时点击新增按钮,部分机型会直接调起相机,注意,各型号手机表现不同,请谨慎使用。handleClick为true时,此属性无效add-image
emit时机: 当handleClick参数为true时,点击新增按钮参数: 无备注: 无remove-image
emit时机: 当handleClick参数为true时,点击删除按钮参数: 无备注: 当handleClick为false时,点击删除按钮,组件内部删除第一张图片;否则,用户需要监听本事件,并进行相应删除操作preview
emit时机: 点击任意一张图片的时候参数: 图片对象,格式为 { url: 'imgUrl' }备注: 暂时没有实现自动预览功能,如果需要用户监听事件自行实现upload-image
emit时机: handleClick和autoUpload都为false`时,选择图片参数: formData,图片内容生成的formData备注: 可以通过vm.$refs.input获取图片的input元素FAQs
vux-upload-component, the component to upload images
The npm package vux-upload-component receives a total of 11 weekly downloads. As such, vux-upload-component popularity was classified as not popular.
We found that vux-upload-component demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Socket now supports Custom Roles and Repository Access Permissions so organizations can control who can access specific repositories and actions.

Product
Socket MCP now lets AI assistants review org alerts, investigate threats using the Socket threat feed, and inspect package files in addition to dependency scoring.

Product
Socket Firewall blocks malicious VS Code and Open VSX extensions before install, protecting developers from compromised editor marketplaces.