0

我收到一个错误:Uncaught TypeError: Cannot read property '1' of null。这是什么意思?错误的来源是以下行id: file.meta['key'].match(/^cache\/(.+)/)[1]

uppy.on('upload-success', (file, response) => {
 // construct uploaded file data in the format that Shrine expects
 const uploadedFileData = {
  id: file.meta['key'].match(/^cache\/(.+)/)[1], // object key without prefix
  storage: 'cache',
  metadata: {
   size: file.size,
   filename: file.name,
   mime_type: file.type,
  }
 }

 // set hidden field value to the uploaded file data so that it's submitted
 // with the form as the attachment
 hiddenInput.value = JSON.stringify(uploadedFileData)
})

我认为这是试图在不存在的索引处选择一些东西,但是……什么索引确实存在?

4

1 回答 1

0

问题是这id: file.meta['key'].match(/^cache\/(.+)/)[1]Shrine.storage. 我的前缀是uploads/cache. 我只需要将其改回cache.

于 2020-10-03T17:06:54.360 回答