vue init webpack myproject cd my vue cnpm/npm install cnpm/npm run dev
<template>
<div id="wrapper">
<router-view></router-view>
</div>
</template>
<script>
export default {
data () {
return {
}
},
components: {
}
}
</script>
import Vue from 'vue'
import App from './App'
import Home from './pages/Home.vue'
import VueRouter from 'vue-router'
import 'bootstrap/dist/css/bootstrap.css'
Vue.use(VueRouter)
const routes = [{
path: '/',
component: Home
}]
const router = new VueRouter({
routes
})
/* eslint-disable no-new */
new Vue({
el: '#app',
router,
template: '<App/>',
components: { App }
})
<template>
<div class="jumbotron">
<h1>这个是路由对应的页面,下面就是一个表格组件</h1>
<table-com/>
</div>
</template>
<script>
import table from '../components/Hello.vue'
export default {
data () {
return {
}
},
components: {
tableCom: table
}
}
</script>
<template>
<div style="padding:20px;" id="app">
<div class="panel panel-primary">
<div class="panel-heading">用户管理</div>
<table class="table table-bordered table-striped text-center">
<thead>
<tr>
<th>序号</th>
<th>用户名</th>
<th>年龄</th>
<th>毕业学校</th>
<th>操作</th>
</tr>
</thead>
<tbody>
<tr v-for ="(user,index) in users">
<td>{{index+1}}</td>
<td>{{user.name}}</td>
<td>{{user.age}}</td>
<td>{{user.school}}</td>
<td><button v-on:click="remove(index)">remove</button></td>
</tr>
<tr>
<td></td>
<td><input type="text" id="name" v-model="user.name"/></td>
<td><input type="text" id="age"v-model="user.age"/></td>
<td><input type="text" id="school"v-model="user.school"/></td>
<td><button @click="insert">insert</button></td>
</tr>
</tbody>
</table>
</div>
</div>
</template>
<script>
export default {
name: 'hello',
data () {
return {
user: {'name': '', 'age': '', 'school': ''},
users: [
{'name': '李磊', 'age': '25', 'school': '洛阳理工'},
{'name': '张成', 'age': '23', 'school': '桂林电子科技'},
{'name': '炼心', 'age': '22', 'school': '江西电子科技'}
]
}
},
methods: {
insert: function () {
this.users.push(this.user)
},
remove: function (index) {
this.users.splice(index, 1)
}
}
}
</script>
<!-- Add "scoped" attribute to limit CSS to this component only -->
<style scoped>
h1, h2 {
font-weight: normal;
}
ul {
list-style-type: none;
padding: 0;
}
li {
display: inline-block;
margin: 0 10px;
}
a {
color: #42b983;
}
tr,th{
text-align:center;
}
</style>
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有