[Vue warn]: Error in callback for watcher “fileList“: “TypeError: Cannot create property ‘uid‘ on


foreword

Hello everyone, today I will share with you a project error report and the solution to this error report.
I am currently using a recording background management developed by Vue3+element plus. In the previous article, I also posted an article about uploading recordings. These two are the same project, because some requirements have been changed, and now the changes appear I have reported an error, and the following will talk about the cause and solution of this error.

1. The reason for the error

The specific error report is as shown in the figure below:
insert image description here
This problem occurs because the type is wrong, which leads to the error report.
insert image description here
I am using the upload upload component in element plus. You can see that I have used a file-list attribute. This attribute is the main reason for the error. We can see how the official document describes it.
insert image description here
What this property needs is an array, and the array contains the object type. The previous requirement of this project was that I gave it a comma-separated string, but it has been changed now, so if your type is wrong, an error will be reported.
Another method was used before the requirements were changed. After the requirements were changed, I did not pay too much attention to this part, resulting in an error.
Let me tell you how to solve this problem.

Two, the solution

insert image description here
This is the code after I changed it. I push the path of the voice into this array in the form of an object, and then loop through it after confirming the edit, and put the path of each picture into an array.
insert image description here
This solves the problem of this error.
I also searched when I changed it, and there are many methods, but the root cause of the problem is still the same.
Everyone has their own ideas and habits, and their own methods of solving problems. A method that can solve problems is a good method.

Summarize

The above is the whole content of this chapter. I don’t know whether my own is the best, and there must be some big guys who write better than me, but I want to share my solution and some insights. When someone encounters the same When there is a problem, there can be one more solution. If there is a problem with my method or a better solution, I hope you can bring it up to me and thank you.
I hope this article can help you, let us improve and make progress together!

Guess you like

Origin blog.csdn.net/SqlloveSyn/article/details/131991044