vue version: 2.x
First, Duplicate keys detected: ‘0’. This may cause an update error is an error caused by Vue finding that the key is not unique.
Translated into Chinese is probably: Duplicate key detected: ‘0’. ‘0’ may cause an update error.
There are also some other solutions found on the Internet. It is solved by manual modification :key
, such as concatenating strings. Because in order to solve the problem, the data is manually modified. Personally, it should not be like this.
The last problem I found: On the same layer of DOM node, vue found that the key is not unique. It will report an error. But if you are not using the v-for loop in the same layer of DOM, you will not report an error. So, if it is not in the same layer of DOM The for loop on the above can ensure the uniqueness of the key. (The role of the key has not been touched yet.)
And the solution:
What I think of is to add an extra layer of html tags, but this will create more non-semantic tags, just to ensure the uniqueness of the key and add tags, but I prefer to do this instead of manually splicing strings.
Or manual splicing recommended on the Internet. But: the key is manually modified. If you forget: the key data is different from the original data. It is not so convenient to maintain in the later stage.
Sample Code
< script type = "text/javascript" src = "./vue_localtion/vue.js" > </ script > </ head > < body > < div id = "app" > < p v-for = '(item,index) in cyclicData' :key = 'index' > {{item}} </ p > < hr > < div > <!--If you remove this layer of div, an error will be reported. Because on the same layer of DOM node: the value of the key is repeated --> < p v-for = '(item,index) in sortCyclicData' :key = 'index' > {{item}} </ p > </ div > </ div > < script > let app = new Vue({ el : '#app' , data : { cyclicData : [ 1 , 8 , 3 , 7 , 5 , 6 ], }, computed : { sortCyclicData : function () { return this .cyclicData.sort( function ( num1, num2 ) { return num1-num2; }) } }, }) </ script >
Read More:
- Vue el-table Error: Duplicated keys detected This may casuse an update error
- Vue Cli error: vuecliYou may need an additional loader to handle
- [Solved] Vue cli version is @ Vue/cli 4.5.13, and sass is used to report an error
- Windows update failed to update, indicating the solution of 0x80244021
- Introduce wangeditor5 to run an error: You may need an appropriate loader to handle this file type (es6 compatibility issue)
- Solve the VUE startup problem (You may use special comments to disable some warnings)
- Vue Report Error #NULL! :no such file or directory,chmod….. [email protected] **\css- Beautify.js
- Uniapp: TypeError: Cannot read property ‘apply‘ of undefined (H5 does not report an error, but the real machine runs with an error)
- [Solved] R Language Error: duplicate ‘row.names’ are not allowed
- [Solved] JNI DETECTED ERROR IN APPLICATION: GetStringUTFChars received NULL jstring
- Solution: the solution to the wrong connection of rosdep init or rosdep update
- [Solved] Laravel reports an error when executing composer update
- [Solved] react Error: Can‘t perform a React state update on an unmounted component
- laravel Error mews/captcha is locked to version 3.2.4 and an update of this package was not requested.
- [Solved] Unity3d reports an error using the opencv plug-in: unsafe code may only appear if compiling with/unsafe.
- [Solved] NDK JNI DETECTED ERROR IN APPLICATION: use of deleted local reference
- [Solved] NPM Error: gyp: No Xcode or CLT version detected!
- [Solved] An unexpected error has occurred. Conda has prepared the above report.
- Vue Import Baidu map error: BMap is not defined, eslint BMap reports an error
- EF core Creates pg library and Model Report an Error [Solved]