编写简单的button配合input实现上传文件操作
<template>
<button>
导入文件
<input type="file" @change="fileChange" accept=".*" :disable="disable"/>
</button>
</template>
<script>
data(){
return{
disable: false
}
}
methods: {
fileChange(event){
// 文件处理函数
let files = event.target.files
let tempData = new FormData()
for(let i = 0; i < files.length; i++){
let file = files[i]
tempData.append(file.name, file, file.name)
}
// 上传请求函数
...
}
}
</script>
<style>
button {
podition: relative;
overflow: hidden;
input {
position: absolute;
top: 0;
left: 0;
opacity: 0;
width: 100%;
height: 100%;
font-size: 0;
cursor: pointer;
}
button:disable {
color: #ccc;
background-color: #ccc;
border-color: #aaa;
cursor: not-allowed;
input {
cursor: not-allowed;
}
}
}
</style>
编写简单的button配合input实现上传文件操作的更多相关文章
- 通过cmd完成FTP上传文件操作
一直使用 FileZilla 这个工具进行相关的 FTP 操作,而在某一次版本升级之后,发现不太好用了,连接老是掉,再后来完全连接不上去. 改用了一段时间的 Web 版的 FTP 工具,后来那个页面也 ...
- input file 上传文件
面试的时候遇到一个问题,要求手写的方式上传文件. 本来觉得很简单,但是结果怎么也成功不了. 前台: <form ID="form1" action="AcceptF ...
- ajax+ashx 完美实现input file上传文件
1.input file 样式不能满足需求 <input type="file" value="浏览" /> IE8效果图: Firefox效 ...
- 巧妙利用label标签实现input file上传文件自定义样式
提到上传文件,一般会想到用input file属性来实现,简单便捷,一行代码即可 但input file原生提供的默认样式大多情况下都不符合需求,且在不同浏览器上呈现的样式也不尽相同 我们往 ...
- input 限制 上传文件类型
参考:input file控件限制上传文件类型 HTML <input> 标签的 accept 属性 网页上添加一个input file HTML控件: <input id=&quo ...
- 使用input file上传文件中onChange事件只触发一次问题
每次上传文件的时候,都会将当前的文件路径保存至$event.target.value中,当第二次选择文件时,由于两次$event.target.value相同,所以不会触发change事件. 解决方案 ...
- 在HTML5的 input:file 上传文件类型控制 遇到的问题
1.input:file 属性的介绍 先瞅代码吧 <form> <input type="file" name="pic" accept=& ...
- input 原生上传文件(type = file)
1.表单上传文件的步骤: - 1)设置enctype 默认为:enctype="application/x-www-form-urlencoded"(一般不设置) 若要表单中有需要 ...
- input file上传文件
如何使用input[type='file']来上传文件呢? html: //angular<input type="file" (change)="fileChan ...
- $_FILES参数详解及简单<form>表单无刷新上传文件
$_FILES:经由 HTTP POST 文件上传而提交至脚本的变量,类似于旧数组$HTTP_POST_FILES 数组(依然有效,但反对使用)详细信息可参阅 POST方法上传 $_FILES数组内容 ...
随机推荐
- C语言学习--练习--合并两个字符串
将两个字符串合并追加在一起, 类似于python的str1+str2 #include<stdio.h> #include<string.h> #include<stdl ...
- dvwa sql盲注教程
原文地址:https://www.jianshu.com/p/757626cec742 一.DVWA-SQL Injection(Blind)测试分析 SQL盲注 VS 普通SQL注入: 普通SQL注 ...
- Qt事件处理的几种方式
Qt提供了5种事件处理和事件过滤的方法: 1.重写事件处理器函数 这是大部分情况最常用的一种,如重写 paintEvent().mousePressEvent().keyPressEvent() 等事 ...
- CentOS网络服务操作命令
CentOS 重启网络服务,输入下面的命令:systemctl retart network.service 或 systemctl restart network.CentOS 启动网络服务,输入下 ...
- mac_office2019
mac_office2019下载 1,链接地址: mac_office2019: https://590m.com/d/28636472-44062040-dc385f (访问密码:7410) 2, ...
- css - contenteditable
css - contenteditable contenteditable属性 contenteditable 属性是 HTML5 中的新属性.规定是否可编辑元素的内容. 让contenteditab ...
- Chrome 中设置默认搜索引擎为 google.com
https://google.com/search?q=%s&ref=opensearch&safe=off 那么就可以使搜索结果默认在新标签页打开,同时关闭了搜索结果的安全过滤. ...
- How to use lspci, lsscsi, lsusb, and lsblk to get Linux system devices information
There are many utilities available to check Linux system hardware information. Some commands report ...
- Leecode-每日一题-题目448. 找到所有数组中消失的数字
今天重新开始刷leecode 为了致敬我的偶像,还是选择把做题笔记发在博客园上 题目448. 找到所有数组中消失的数字 给定一个范围在 1 ≤ a[i] ≤ n ( n = 数组大小 ) 的 整型数 ...
- spring-security-oauth2-authorization-server
旧依赖的移除 长久以来,使用Spring Security整合oauth2,都是使用Spring Security Oauth2这个系列的包: <dependency> <group ...