html5用户管理页面,vue-用户管理

一、JSON Server

1. 全局安装JSON Server

npm install -g json-server

2. 创建一个文件夹JSONSERVER

3. 初始化文件夹

npm init --yes,进行一些配置后,文件夹会多出package.json文件

4. 安装json server

npm install json-server --save (--save 保存到package.json)

5. 修改scripts

47049a0f0efd

scripts.png

6. 编写db.json文件

7. npm run json:server

二、Main.js(没使用app.vue)

import Vue from 'vue'

import VueRouter from 'vue-router'

import App from './App'

import Customers from './components/Customers'

import About from './components/About'

import Add from './components/add'

import CustomerDetails from './components/CustomerDetails'

import VuesResouce from 'vue-resource'

import Edit from './components/Edit'

Vue.config.productionTip = false

Vue.use(VueRouter)

Vue.use(VuesResouce)

// 设置路由

const router = new VueRouter({

mode:"history",

base:__dirname,

routes:[

{path:"/",component:Customers},

{path:"/about",component:About},

{path:"/add",component:Add},

{path:"/customer/:id",component:CustomerDetails},

{path:"/edit/:id",component:Edit}

]

})

/* eslint-disable no-new */

new Vue({

router,

template: `

`

}).$mount("#app")

三、使用bootstrap(index.html中)

vcustomers

四、Customers.vue(用户信息展示)

47049a0f0efd

1559270161(1).png

47049a0f0efd

1559270287(1).png

五、add.vue(用户添加)

47049a0f0efd

1559271051(1).png

47049a0f0efd

1559274389(1).png

六、Alert.vue(提示框,在主页,添加,编辑用到)

47049a0f0efd

1559287418(1).png1.在Customers.vue中

47049a0f0efd

1559288721.png

47049a0f0efd

1559288848(1).png

七、CustomerDetails.vue(用户详细信息)

返回

{{customer.name}}

编辑

删除

  • {{customer.phone}}

  • {{customer.email}}

export default {

name: 'customerdetials',

data () {

return {

customer:""

}

},

methods:{

fetchCustomers(id){

this.$http.get("http://localhost:3000/users/"+id)

.then(function(response){

console.log(response)

this.customer=response.body

})

},

deleteCustomer(id){

this.$http.delete("http://localhost:3000/users/"+id)

.then(function(response){

this.$router.push({path : "/", query:{alert:"用户删除成功"}});

})

}

},

created() {

this.fetchCustomers(this.$route.params.id);

},

}

七、Edit.vue(编辑页面)

47049a0f0efd

1559290105(1).png

47049a0f0efd

1559290691(1).png

$route.path字符串,等于当前路由对象的路径,会被解析为绝对路径,如 "/home/news" 。

$route.params对象,包含路由中的动态片段和全匹配片段的键值对

$route.query 对象,包含路由中查询参数的键值对。例如,对于 /home/news/detail/01?favorite=yes ,会得到$route.query.favorite == 'yes' 。

$route.router 路由规则所属的路由器(以及其所属的组件)。

$route.matched 数组,包含当前匹配的路径中所包含的所有片段所对应的配置参数对象。

$route.name 当前路径的名字,如果没有使用具名路径,则名字为空。

八、搜索功能

47049a0f0efd

1559293219(1).png

其中filter和match为es6语法

47049a0f0efd

1559293326(1).png

八、axios

用axios代替vue-resource

47049a0f0efd

1559295405(1).png

=>代替function,为了取到this

body变成data

47049a0f0efd

1559295586(1).png

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值