Vue For Key
Track tasks and feature requests
Dec 26, 2017 - Having a unique key solves this problem. The key acts as a sort of flag that tells Vue 'if the data associated with this child component is moved. Sep 8, 2018 - When you need the component to be re-rendered, you just change the value of the key and Vue will re-render the component. It's a pretty.
Join 36 million developers who use GitHub issues to help identify, assign, and keep track of the features and bug fixes your projects need.
Sign up for free See pricing for teams and enterprisesHave a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
commented Jul 27, 2017 • edited
edited
What problem does this feature solve?In our business system, there is so many :key object used. What does the proposed API look like? |
commented Jul 27, 2017 • edited
edited
You can use the more at https://vuejs.org/v2/guide/list.html#key |
commented Jul 28, 2017 • edited
edited
@posva , you can see this issue : #5410 @yyx990803 :
@posva ,I know, if there a show list, we don't need it, but we has so many edit things. |
commented Jul 28, 2017
@vvpvvp, that's the point, we vue can not know how developer wants |
commented Jul 28, 2017
@nickmessing , I just want v-for has no question when i use it normal. and, If I don't use key, there is some problem we not expected. |
commented Jul 28, 2017
I thought you were forcing yourself to use a key. You don't always need keys |
commented Jul 28, 2017
@posva , I thought you are missing this point :
I don't want force myself to use a key, it's because if I don't use it, it will be something wrong. |
commented Jul 28, 2017 • edited
edited
that's why I told you to use the index.. because it should be the same.. |
commented Jul 28, 2017 • edited
edited
Hi @vvpvvp |
commented Jul 28, 2017
@vvpvvp , the point is Vue cannot infer a unique key for you, what vue can do and already does is to infer a key based on index. If there are operations like 'add' or 'delete' elements in list, you really should generate a unique yourself. A simply counter could do the trick. |
commented Jul 28, 2017 • edited
edited
@Kingwl , I understand. |
changed the titlev-for : add a prop 'uniqueKey' to generates a uniqueKey automaticallyJul 28, 2017
commented Jul 28, 2017 • edited
edited
@vvpvvp calm down my friend and IMO this behavior is not normal..i(we) will try to improve it |
commented Jul 28, 2017
Vue cannot generate the unique keys for you because it doesn't know how or when you add or delete items. But it's super easy to add an id. Without using hash you can use an incrementing id: https://codepen.io/posva/pen/BdoJJz |
commented Jul 28, 2017 • edited
edited
he told you that is a |
commented Jul 28, 2017 • edited
edited
IMO the feature of supporting object type keys is more constructive than this, and it's likely to be implemented in the future. See #5804 (comment) As you know, the unique key must be attached to the item object, when it's automatically generated inside Vue, it may cause some problems if users are unaware of that. Here's a demo - https://jsfiddle.net/xujiongbo/3wt7hv7c/ |
commented Jul 28, 2017
By default, Vue uses the index of the items since it's the only thing it can do without having to 'guess' what the developer wants. |
commented Jul 28, 2017
@posva ,
no..... 1st, it' s ugly. 2nd, it's easy to add an id in a simple demos. but, it's not easy to add an id in our complex datas with complex system. and the data is nested structure. and it's nested and nested and nested.. finally, it 's good in vue1.0 , and we don't need key at all, I know vue mechanism changed, I just wonder if there is some way can handle it, it will be so helpful. tips: it's not only v-for problems, some adjacent element with directive used, if you don't add some key, it's also has some problem. @Kingwl , my English is not good, maybe my words is not readability, I'm sorry about it, but I am also peaceful. |
commented Jul 28, 2017 • edited
edited
Why?
Don't you have fields in your data to make them unique? How do you make the relations between your objects?
If you want the default behavior, you can just use the index: Note that you don't need this if you are looping over HTML standard elements. |
commented Jul 28, 2017
I wrote very slowly, so when i complete my answer, always a new answer to me. @javoski , you are so kindly, function vue can't change the datas we define, and also I can't change the data used on my ui components, like table component and so on. I wrote an ui toolkit with vue2.0, http://www.heyui.top/component, if i used kind of |
commented Jul 28, 2017
@Akryum , I don't want to answer it so many times. index is not useful, please read this demo . link: https://codepen.io/vvpvvp/pen/oZKpgE |
commented Jul 28, 2017
@vvpvvp I was answering just a part of your comment. As you should know by now, your issue will be resolved when you will provide a unique key for each item in your data. |
commented Jul 28, 2017
Let's move the discussion to the Discord server (or the forum). Other people will be able to help you with insights that are more specific to your project @vvpvvp |
commented Sep 7, 2017
@vvpvvp I came to a similar situation using Vue components inside a list that it can be edited (add/remove items and change the order using VueDraggable). Items haven't any unique id because they are generated data within a form. The solution I've found is to use a 'shadow' list where I save unique ids, for rendering purpose, and to edit both lists on user interaction. Here is an example using your code |
commented Sep 8, 2017
@nauzethc, thank you very much. |
commented Sep 8, 2017
@vvpvvp, i understand your problem. |
commented Mar 20, 2018
I came across this issue and resolved it by adding 'key' attribute with Date.now() value as a key. |
commented Mar 21, 2018
e.. |
commented Jul 5, 2018
@mohd-isa • On Windows 8.1 and Windows Server 2012 R2, it’s listed as Update for Microsoft Windows (KB3102467) under the Installed Updates item in Control Panel. Download microsoft net framework 4.6 1 offline installer. After you install this package, you can see that the following packages or updates were installed, depending on your operating system: • On Windows 7 SP1 and Windows Server 2008 R2 SP1, the Microsoft.NET Framework 4.6.1 is listed as an installed product under the Programs and Features item in Control Panel. We recommend that you use the web installer instead of the offline installer when possible for optimal efficiency and bandwidth requirements. • On Windows 8 and Windows Server 2012, it’s listed as Update for Microsoft Windows (KB3102439) under the Installed Updates item in Control Panel. Actually, the problem appears in cases we can't get UID from item; items could change (they come as a props for ex.); they should take place simultaneously (transition-group, for ex.). IMO, the best way is provide build-in mechanism for generating UIDs. That isn't hard to write helpers, it's hard to do it every time in every project. |
commented Jul 5, 2018
Please refer to https://vuejs.org/v2/guide/list.html#key to see all the implications about setting a A built-in mechanism to generate UID have no place in Vue as it is not related to building interfaces. |
locked and limited conversation to collaborators Jul 5, 2018
NCEES Computer-Based Exams NCEES is a national nonprofit organization responsible for developing and scoring the examinations used for engineering and surveying licensure in the United States, the District of Columbia, Guam, the Northern Mariana Islands, Puerto Rico, and the U.S. Virgin Islands. It has contracted with Pearson to administer and score the Fundamentals of Engineering (FE), Fundamentals of Surveying (FS), and Principles and Practice of Surveying (PS) exams. Exam Registration and Scheduling Information. Registration Registration for computer-based exams is accessible 7 days per week, 24 hours per day, through a valid MyNCEES account only.
Visit ncees.org to log in or create an account. Examinees will receive an email notification once they have successfully completed the registration process and have been authorized to schedule an exam. Scheduling Upon receiving authorization to schedule an appointment, examinees should log in to their, select the “SCHEDULE” option and follow the on-screen instructions. Appointments for computer-based exams are currently available during the following testing windows: January - March April - June July - September October - December Rescheduling and Cancellations Examinees are able to reschedule or cancel an appointment by logging into their, selecting the “Modify Appointment” option and following the on-screen instructions. All associated fees are payable to Pearson and subject to applicable fees. Please note that canceling your exam will cancel your authorization to test and require you to reapply and pay for the exam. If applicable, refunds will be automatically applied by NCEES.
Practice Exam Information NCEES discontinued computer-based practice exams on February 28, 2017. If you still have a valid computer-based practice exam, it is available through your MyNCEES account. Familiarize yourself with the look, feel and navigation of a Pearson VUE computer-based test.