
首先在main.js引入 import { Form,Field } from ‘vant’;
Vue.use(Form);
Vue.use(Field);
vue文件 js 写入
data() {
return {
files: [], //图片
imgList: [],
};
},
methods: {
// 图片信息
toChooseImg(file) {
let localData = file.content;
this.uploadImg(localData.split(",")[1]);
},
// 上传图片到服务器
uploadImg(img) {
this.$http
.postRequest("/frontEnd/F/F001", {
file_type: "1",
attach_type: "photo",
file_ext: "jpeg",
image: img,
toAliyun: "1",
})
.then((res) => {
if (res.result != "0") {
this.$toast.fail(res.msg);
} else {
this.files.push(res.filePath);
}
});
},
// 删除图片
delPic(idx) {
this.imgList.splice(idx, 1);
this.files.splice(idx - 1, 1);
},
},
欢迎分享,转载请注明来源:内存溢出
微信扫一扫
支付宝扫一扫
评论列表(0条)