Home > front end > Rookie inquired, the great god to solve!
Rookie inquired, the great god to solve!
Time:09-27
Do a simple test system, now need to use ajax determine whether to submit the answer and the correct answer is consistent, the same word can continue to the next topic, it is not the same silently, and prevent click one button operation, ask how to do it, not really,,,
CodePudding user response:
<script SRC="https://cdn.bootcss.com/vue/2.6.11/vue.js" & gt; </script> <script SRC="https://cdn.bootcss.com/vue/2.6.11/vue.min.js" & gt; </script> <script SRC="https://cdn.bootcss.com/jquery/1.8.3/jquery.js" & gt; </script> New Vue ({ El: '# app, Data: { Answer: "11111", The list: { "Id" : "1101", "Question" : "simulation data can use mock?" , "Answer" : "must be" } ]
}, Mounted () { The console. The log (1111=& gt; "" , enclosing a list); }, Methods: { Next () { The console. The log (" get the user input data====& gt;" , this answer); //statement since the data is only virtual data here, so the front circulation judgment can temporarily /* * if the backend interface, the answer to the user directly to the input as a parameter to * */ For (var. I in this list) { If (this. The list [I]. Answer==this. Answer) { Alert (" correct answer "); } else { Alert (" wrong answer "); } }