vue動態(tài)刪除從數(shù)據(jù)庫倒入列表的某一條方法
更新時間:2018年09月29日 09:32:40 作者:俊人呀
今天小編就為大家分享一篇vue動態(tài)刪除從數(shù)據(jù)庫倒入列表的某一條方法,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧
如下所示:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title></title>
//導入vue.js
<script type="text/javascript" src="./vue.js"></script>
//非常簡單了設置了一下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動態(tài)刪除從數(shù)據(jù)庫倒入列表的某一條方法就是小編分享給大家的全部內容了,希望能給大家一個參考,也希望大家多多支持腳本之家。
您可能感興趣的文章:
- vue.js基于v-for實現(xiàn)批量渲染 Json數(shù)組對象列表數(shù)據(jù)示例
- vue input輸入框關鍵字篩選檢索列表數(shù)據(jù)展示
- vue實現(xiàn)前臺列表數(shù)據(jù)過濾搜索、分頁效果
- vue 列表頁跳轉詳情頁獲取id以及詳情頁通過id獲取數(shù)據(jù)
- 使用vue根據(jù)狀態(tài)添加列表數(shù)據(jù)和刪除列表數(shù)據(jù)的實例
- 實例分析vue循環(huán)列表動態(tài)數(shù)據(jù)的處理方法
- vue主動刷新頁面及列表數(shù)據(jù)刪除后的刷新實例
- 使用vue框架 Ajax獲取數(shù)據(jù)列表并用BootStrap顯示出來
- Vue如何獲取數(shù)據(jù)列表展示
相關文章
Vue3+Vite項目中引入pinia和pinia-plugin-persistedstate的方法代碼
這篇文章主要給大家介紹了關于Vue3+Vite項目中引入pinia和pinia-plugin-persistedstate的相關資料,Pinia是Vue.js的官方狀態(tài)管理庫,輕量且功能強大,支持模塊化和TypeScript,PiniaPluginPersistedState是一個插件,需要的朋友可以參考下2024-11-11
全局安裝 Vue cli3 和 繼續(xù)使用 Vue-cli2.x操作
這篇文章主要介紹了全局安裝 Vue cli3 和 繼續(xù)使用 Vue-cli2.x操作,具有很好的參考價值,希望對大家有所幫助。一起跟隨小編過來看看吧2020-09-09
vue3中element-plus?icon圖標的正確使用姿勢
element-plus官方提示,Icon圖標正在向SVG?Icon遷移,之前使用的Font?Icon即將被棄用,下面這篇文章主要給大家介紹了關于vue3中element-plus?icon圖標的正確使用姿勢,需要的朋友可以參考下2022-03-03
Vue3中當v-if和v-for同時使用時產生的問題和解決辦法
封裝一個組件時,我使用到了v-for和v-if,它們在同一標簽內,總是提示v-for循環(huán)出來的item在實例中沒有被定義,查詢資料后原因是因為v-for和v-if在同級使用時,v-if優(yōu)先級比v-for高,所以本文給大家介紹了Vue3中當v-if和v-for同時使用時產生的問題和解決辦法2024-07-07
Vue3 去除 vue warn 及生產環(huán)境去除console.log的方法
這篇文章主要介紹了Vue3 去除 vue warn 及生產環(huán)境去除console.log的方法,本文結合實例代碼給大家介紹的非常詳細,對大家的學習或工作具有一定的參考借鑒價值,需要的朋友可以參考下2023-06-06

