类型改了又改了,一直报错,有点不太理解了
原代码:
import build from '@/common/build.uts'
const request = {}
// Define the get method
request.get = (url, data, option) =>{
return new Promise((resolve, reject) => {
uni.request({
url: `${build.BASE_API_URL}/${url}`,
method: 'GET',
data: data,
...option,
success: (res) => {
resolve(res.data as UTSJSONObject)
},
fail: (err) => {
uni.showToast({
title: '网络请求失败',
icon: 'none'
})
reject(err)
}
})
})
}
export default request
报错:
[plugin:uni:app-uts] 编译失败
11:04:46.110 error: Cannot infer a type for this parameter. Please specify it explicitly.
11:04:46.111 at utils/http.uts:6:15
11:04:46.111 4 |
11:04:46.111 5 | // Define the get method
11:04:46.111 6 | request.get = (url, data, option) =>{
11:04:46.111 | ^
11:04:46.111 7 |
11:04:46.111 8 | return new Promise((resolve, reject) => {
11:04:46.111 error: Cannot infer a type for this parameter. Please specify it explicitly.
11:04:46.111 at utils/http.uts:6:20
11:04:46.111 4 |
11:04:46.111 5 | // Define the get method
11:04:46.111 6 | request.get = (url, data, option) =>{
11:04:46.111 | ^
11:04:46.111 7 |
11:04:46.111 8 | return new Promise((resolve, reject) => {
11:04:46.111 error: Cannot infer a type for this parameter. Please specify it explicitly.
11:04:46.111 at utils/http.uts:6:26
11:04:46.111 4 |
11:04:46.111 5 | // Define the get method
11:04:46.111 6 | request.get = (url, data, option) =>{
11:04:46.111 | ^
11:04:46.111 7 |
11:04:46.111 8 | return new Promise((resolve, reject) => {
11:04:46.111 error: 类型不匹配: 推断类型是CapturedType(),但预期的是Any。
11:04:46.111 at utils/http.uts:9:20
11:04:46.111 7 |
11:04:46.111 8 | return new Promise((resolve, reject) => {
11:04:46.111 9 | uni.request({
11:04:46.111 | ^
11:04:46.111 10 | url: ${build.BASE_API_URL}/${url}
,
11:04:46.111 11 | method: 'GET',
11:04:46.111 error: 类型不匹配: 推断类型是Any,但预期的是CapturedType()。
11:04:46.111 at utils/http.uts:9:20
11:04:46.111 7 |
11:04:46.111 8 | return new Promise((resolve, reject) => {
11:04:46.111 9 | uni.request({
11:04:46.111 | ^
11:04:46.111 10 | url: ${build.BASE_API_URL}/${url}
,
11:04:46.112 11 | method: 'GET',