


Detailed explanation of nested loops, if judgments, and dynamic deletion of images and texts using vue.js
This time I will bring you detailed graphic and text explanations of nested loops, if judgments, and dynamic deletions using vue.js. Notes on using vue.js's nested loops, if judgments, and dynamic deletions. What are they? Here are actual cases. Let’s take a look.
Vue.js is a very popular JavaScript MVVM library. It is built with data-driven and component-based ideas. Compared with Angular.js, Vue.js provides a simpler and easier-to-understand API
app.html
<!doctype html> <html lang="zh-CN"> <head> <meta charset="UTF-8"> <title> vuejs 嵌套循环、if判断 </title> <style type="text/css"> [v-cloak] { display: none } </style> </head> <body> <p id="app"> <table> <tr> <td >id</td> <td >姓名</td> <td >手机号</td> <td >城市</td> <td >通过审核</td> <td >我的学生</td> <td >操作</td> </tr> <tr v-for="(item,index) in list "> <td>{{item.id}}</td> <td>{{item.name}}</td> <td>{{item.tel}}</td> <td>{{item.province}}_{{item.city}}</td> <td v-if="item.status==1">是</td> <td v-else-if="item.status==0">否</td> <td > <span v-for="stu in item.stu "> {{stu.name}}, </span> </td> <td> <button v-on:click="edit">修改</button> <button v-on:click="del(index)">删除</button> </td> </tr> </table> </p> </body> <script src="https://cdn.bootcss.com/jquery/3.2.1/jquery.min.js" charset="utf-8"></script> <script src="https://cdn.bootcss.com/vue/2.3.0/vue.min.js" charset="utf-8"></script> <script type="text/javascript"> $(function() { new Vue({ el: '#app', methods: { del:function(index){ this.list.splice(index,1); }, edit: function () { alert('修改') }, }, data: { "list":[{ "id":"139", "name":"王五", "tel":"13681829898", "status":"1", "province":"省", "city":"市", "sex":"1", "stu":[{ "id":"200", "name":"学生1", "tel":"13681829898", },{ "id":"201", "name":"学生2", "tel":"13681829898", }], }, { "id":"138", "name":"麻子", "tel":"13681829898", "status":"0", "province":"省", "city":"市", "sex":"0", "stu":[{ "id":"300", "name":"学生31", "tel":"13681829898", },{ "id":"301", "name":"学生32", "tel":"13681829898", }], }, { "id":"137", "name":"丽丽", "tel":"15152882891", "status":"0", "province":"省", "city":"市", "sex":"1", "stu":[{ "id":"400", "name":"学生41", "tel":"13681829898", },{ "id":"401", "name":"学生42", "tel":"13681829898", }], }, { "id":"136", "name":"娜娜", "tel":"15152882891", "status":"0", "province":"省", "city":"市", "sex":"0", "stu":[{ "id":"500", "name":"学生51", "tel":"13681829898", },{ "id":"501", "name":"学生52", "tel":"13681829898", }], }] } }) }) </script> </html>
The difference between vue1.0 and vue2.0 loop index usage
如果是vue1.0这样写: <ol> <li v-for="todo in todos" @click="delete($index)"> {{todo.label}} </li> </ol> 然后: methods:{ delete:function(index){ this.todos.splice(index,1); } } 如果是vue2.0这样写: <ol> <li v-for="(todo,index) in todos" @click="delete(index)"> {{todo.label}} </li> </ol> 然后 methods:{ delete:function(index){ this.todos.splice(index,1); } }
I believe you have mastered the method after reading the case in this article, more Please pay attention to other related articles on the php Chinese website!
Recommended reading:
Detailed explanation of the usage of computed, filter, get, set
How to modify the vue request data Value
How to split code based on webpack
The above is the detailed content of Detailed explanation of nested loops, if judgments, and dynamic deletion of images and texts using vue.js. For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



WebSocket and JavaScript: Key technologies for realizing real-time monitoring systems Introduction: With the rapid development of Internet technology, real-time monitoring systems have been widely used in various fields. One of the key technologies to achieve real-time monitoring is the combination of WebSocket and JavaScript. This article will introduce the application of WebSocket and JavaScript in real-time monitoring systems, give code examples, and explain their implementation principles in detail. 1. WebSocket technology

JavaScript and WebSocket: Building an efficient real-time weather forecast system Introduction: Today, the accuracy of weather forecasts is of great significance to daily life and decision-making. As technology develops, we can provide more accurate and reliable weather forecasts by obtaining weather data in real time. In this article, we will learn how to use JavaScript and WebSocket technology to build an efficient real-time weather forecast system. This article will demonstrate the implementation process through specific code examples. We

JavaScript tutorial: How to get HTTP status code, specific code examples are required. Preface: In web development, data interaction with the server is often involved. When communicating with the server, we often need to obtain the returned HTTP status code to determine whether the operation is successful, and perform corresponding processing based on different status codes. This article will teach you how to use JavaScript to obtain HTTP status codes and provide some practical code examples. Using XMLHttpRequest

Question: How to determine whether the date is the previous day in Go language? In daily development, we often encounter situations where we need to determine whether the date is the previous day. In the Go language, we can implement this function through time calculation. The following will be combined with specific code examples to demonstrate how to determine whether the date is the previous day in Go language. First, we need to import the time package in the Go language. The code is as follows: import("time") Then, we define a function IsYest

jQuery is a JavaScript library widely used in web development. It provides many simple and convenient methods to operate web page elements and handle events. In actual development, we often encounter situations where we need to determine whether a variable is empty. This article will introduce several common methods of using jQuery to determine whether a variable is empty, and attach specific code examples. Method 1: Use the if statement to determine varstr="";if(str){co

How to tell if a jQuery element has a specific attribute? When using jQuery to operate DOM elements, you often encounter situations where you need to determine whether an element has a specific attribute. In this case, we can easily implement this function with the help of the methods provided by jQuery. The following will introduce two commonly used methods to determine whether a jQuery element has specific attributes, and attach specific code examples. Method 1: Use the attr() method and typeof operator // to determine whether the element has a specific attribute

Introduction to the method of obtaining HTTP status code in JavaScript: In front-end development, we often need to deal with the interaction with the back-end interface, and HTTP status code is a very important part of it. Understanding and obtaining HTTP status codes helps us better handle the data returned by the interface. This article will introduce how to use JavaScript to obtain HTTP status codes and provide specific code examples. 1. What is HTTP status code? HTTP status code means that when the browser initiates a request to the server, the service

PHP is a scripting language widely used in website development. For developers, it is often necessary to determine whether a field is empty. In PHP, determining whether a field is empty can be achieved through some simple methods. This article will introduce how to determine whether a field is empty in PHP, and provide specific code examples for your reference. In PHP, you can usually use the empty() function or isset() function to determine whether a field is empty. Next, we introduce the usage of these two functions respectively. Use the empty() function
