上传图片

This commit is contained in:
JS-LM
2023-04-23 14:42:30 +08:00
parent b7228b18de
commit d3ba89aeb4

View File

@@ -16,17 +16,31 @@
<div id="container"></div> <div id="container"></div>
</div> </div>
<div class="img"> <div>上传图片</div>
<el-input <el-upload
placeholder="请选择图片" action="https://jsonplaceholder.typicode.com/posts/"
style="width: 50%" list-type="picture-card"
type="file" :on-preview="handlePictureCardPreview"
@change="onFileChange" :on-remove="handleRemove"
ref="iptRef"
></el-input
> >
<el-button style="width: 85px">上传图片</el-button> <!-- :headers="headers"-->
</div> <i class="el-icon-plus"></i>
</el-upload>
<el-dialog :visible.sync="dialogVisible">
<img width="100%" :src="dialogImageUrl" alt="">
</el-dialog>
<!-- <div class="img">-->
<!-- <el-input-->
<!-- placeholder="请选择图片"-->
<!-- style="width: 50%"-->
<!-- type="file"-->
<!-- @change="onFileChange"-->
<!-- ref="iptRef"-->
<!-- ></el-input-->
<!-- >-->
<!--&lt;!&ndash; <el-button style="width: 85px">上传图片</el-button>&ndash;&gt;-->
<!-- </div>-->
</div> </div>
</template> </template>
@@ -41,6 +55,11 @@ window._AMapSecurityConfig = {
export default { export default {
data() { data() {
return { return {
dialogImageUrl: '',
dialogVisible: false,
// headers:{
// Authorization:this.$store.state.user.token
// },
map: null, map: null,
autoOptions: { autoOptions: {
input: "", input: "",
@@ -58,6 +77,14 @@ export default {
}; };
}, },
methods: { methods: {
handleRemove(file, fileList) {
console.log(file, fileList);
},
handlePictureCardPreview(file) {
this.dialogImageUrl = file.url;
console.log(this.dialogImageUrl)
this.dialogVisible = true;
},
// 点击搜索按钮 // 点击搜索按钮
send() { send() {
this.searchPlaceInput = this.inputObject.userInput; this.searchPlaceInput = this.inputObject.userInput;
@@ -160,6 +187,7 @@ export default {
}); });
}, },
onFileChange(e) { onFileChange(e) {
console.log(e,'上传图片')
// 1.获取用户选择的文件列表 // 1.获取用户选择的文件列表
const fileList = e.target.files; const fileList = e.target.files;
console.log(fileList); console.log(fileList);