vue動(dòng)態(tài)刪除從數(shù)據(jù)庫倒入列表的某一條方法
如下所示:
<!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title></title> //導(dǎo)入vue.js <script type="text/javascript" src="./vue.js"></script> //非常簡(jiǎn)單了設(shè)置了一下css樣式 <style type="text/css"> #app{ height: 100%; margin-left: 200px; width:50%; text-align: center; background-color: lightpink } .tab{ width: 600px; margin-top: 30px; background-color: lightpink; } input{ height: 25px; margin-top: 10px; border-radius:5px; } </style> </head> <body> <div id="app"> <div class="createForm"> 姓名:<input type="text" name="uname" v-model="userName"><br> 年齡:<input type="text" name="uage" id="uage" v-model="userAge"><br> 性別:<select name="gender" v-model="selected"> <option v-for="option in options" v-bind:value="option.gender"> {{option.gender}} </option> </select> {{selected}} <br> <button type="button" v-on:click="insertInfo">創(chuàng)建</button> </div> <table class="tab"> <tr style="background-color: pink"> <th>姓名</th> <th>年齡</th> <th>性別</th> <th>刪除</th> </tr> <tr v-for="(person,index) in infoArr"> <td>{{person.uname}}</td> <td>{{person.uage}}</td> <td>{{person.gender}}</td> <td><button v-on:click="deleteInfo(index)">刪除</button></td> </tr> </table> </div> </body> </html> <script type="text/javascript"> new Vue({ el:"#app", data:{ msg:"hello", selected:'女', userName:'', userAge:'', options:[ {gender:"男"}, {gender:"女"} ], infoArr:[] }, methods:{ //添加數(shù)據(jù)的方法 insertInfo(){ var obj={}; obj.uname=this.userName; obj.uage=this.userAge; obj.gender=this.selected; this.infoArr.push(obj); console.log(obj); }, //刪除的方法 deleteInfo(index){ this.infoArr.splice(index,1); } } }) </script>
以上這篇vue動(dòng)態(tài)刪除從數(shù)據(jù)庫倒入列表的某一條方法就是小編分享給大家的全部?jī)?nèi)容了,希望能給大家一個(gè)參考,也希望大家多多支持腳本之家。
- vue.js基于v-for實(shí)現(xiàn)批量渲染 Json數(shù)組對(duì)象列表數(shù)據(jù)示例
- vue input輸入框關(guān)鍵字篩選檢索列表數(shù)據(jù)展示
- vue實(shí)現(xiàn)前臺(tái)列表數(shù)據(jù)過濾搜索、分頁效果
- vue 列表頁跳轉(zhuǎn)詳情頁獲取id以及詳情頁通過id獲取數(shù)據(jù)
- 使用vue根據(jù)狀態(tài)添加列表數(shù)據(jù)和刪除列表數(shù)據(jù)的實(shí)例
- 實(shí)例分析vue循環(huán)列表動(dòng)態(tài)數(shù)據(jù)的處理方法
- vue主動(dòng)刷新頁面及列表數(shù)據(jù)刪除后的刷新實(shí)例
- 使用vue框架 Ajax獲取數(shù)據(jù)列表并用BootStrap顯示出來
- Vue如何獲取數(shù)據(jù)列表展示
相關(guān)文章
Vue中動(dòng)態(tài)Class實(shí)戰(zhàn)示例
這篇文章主要為大家介紹了Vue中動(dòng)態(tài)Class的實(shí)戰(zhàn)示例,有需要的朋友可以借鑒參考下,希望能夠有所幫助,祝大家多多進(jìn)步,早日升職加薪2023-11-11Vue3+Tsx給路由加切換動(dòng)畫時(shí)的踩坑及解決
這篇文章主要介紹了Vue3+Tsx給路由加切換動(dòng)畫時(shí)的踩坑及解決,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。如有錯(cuò)誤或未考慮完全的地方,望不吝賜教2023-01-01Vue3父子組件傳參有關(guān)sync修飾符的用法詳解
這篇文章主要給大家介紹關(guān)于前端Vue3父子組件傳參有關(guān)sync修飾符的用法詳細(xì)解析,有需要的朋友可以借鑒參考下,希望能夠有所幫助2021-09-09Vuejs仿網(wǎng)易云音樂實(shí)現(xiàn)聽歌及搜索功能
這篇文章主要介紹了Vuejs仿網(wǎng)易云音樂實(shí)現(xiàn)聽歌及搜索功能,非常不錯(cuò),具有參考借鑒價(jià)值,需要的朋友可以參考下2017-03-03Vue3 響應(yīng)式 API 及 reactive 和 ref&
響應(yīng)式是一種允許以聲明式的方式去適應(yīng)變化的編程范例,這篇文章主要介紹了關(guān)于Vue3響應(yīng)式API及reactive和ref的用法,需要的朋友可以參考下2023-06-06Vue在H5 項(xiàng)目中使用融云進(jìn)行實(shí)時(shí)個(gè)人單聊通訊
這篇文章主要介紹了Vue在H5 項(xiàng)目中使用融云進(jìn)行實(shí)時(shí)個(gè)人單聊通訊,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下2020-12-12解決vue2.0動(dòng)態(tài)綁定圖片src屬性值初始化時(shí)報(bào)錯(cuò)的問題
下面小編就為大家分享一篇解決vue2.0動(dòng)態(tài)綁定圖片src屬性值初始化時(shí)報(bào)錯(cuò)的問題,具有很好的參考價(jià)值,希望對(duì)大家有所幫助。一起跟隨小編過來看看吧2018-03-03