//main.js
Vue.prototype.$imageUrl ="http://www.com/baidu.com" //上传图片地址
uploadImg() {
uni.chooseImage({
count: 1, //默认9
sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
sourceType: ['album', 'camera'], //从相册选择和拍照
success: res => {
this.pho = res.tempFilePaths[0]
uni.uploadFile({
url: this.$imageUrl, //上传的服务器地址 在vue上了,直接用
filePath: res.tempFilePaths[0],
name: "image",
success: res => {
var obj = JSON.parse(res.data)
this.uploadpho = obj.data
this.pho = this.url + obj.data
}
})
}
})
},