Vue框架小案例和bootstrap框架的css樣式
阿新 • • 發佈:2019-01-04
<!DOCTYPE html>
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content ="width=device-width, initial-scale=1">
<link rel="stylesheet" href="bootstrap.min.css">
</head>
<body>
<!--[if lt IE 7]>
<p class="browsehappy">You are using an <strong>outdated</strong> browser. Please <a href="#">upgrade your browser</a> to improve your experience.</p>
<![endif]-->
<div id="app">
<!-- {{test}} -->
<div class="panel panel-primary">
<div class="panel-heading">新增品牌</div>
</div>
<div id="app" class="panel panel-default">
<!-- Default panel contents -->
<div class="panel-body">
<!-- <p>...</p> -->
<!-- ID:<input type="text" placeholder="ID" v-model="ID"> 品牌名稱:<input type="text" placeholder="品牌名稱" v-model="lastName"> <button @click="update">新增</button> -->
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">ID</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="ID" v-model="id">
</div>
<div class="form-group">
<label for="exampleInputEmail2">品牌名稱</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="品牌名稱" v-model="pinpai">
</div>
<button type="submit" class="btn btn-default" @click="updateP" style="background: #3CA9C4; color: white ">新增</button>
</form>
</div>
<!-- Table -->
<table class="table">
<tr>
<td class="active" style="">ID</td>
<td class="success">品牌名稱</td>
<td class="warning">操作(Operation)</td>
</tr>
<tr v-for="(p, index) in content" :key="index">
<td>{{p.ID}}</td>
<td>{{p.pinpai}}</td>
<td><button @click="deleteP(index)">刪除</button></td>
</tr>
</table>
</div>
</div>
<script src="" async defer></script>
<script type="text/javascript" src="vue.js"></script>
<script type="text/javascript">
new Vue({
el:'#app',
data:{
test:'這是一個測試資料',
id:'',
pinpai:'',
content:[
{ID:'1',pinpai:'賓士'},
{ID:'2',pinpai:'寶馬'}
]
},
methods: {
deleteP(index){
this.content.splice(index, 1);
},
updateP(){
this.content.push({ID:this.id,pinpai:this.pinpai})
}
},
})
</script>
</body>
</html>