1. Create

    this.$http.post("http://localhost:3000/users",newCustomer).then(function (response) {
this.$router.push({path: "/", query:{alert: "用户信息添加成功!"}});
//$router对象是全局路由的实例,是router构造方法的实例。
});

2. Retrieve

           this.$http.get("http://localhost:3000/users/"+id)
.then(function (response){
console.log(response);
this.customer = response.body;
})

3. Update

            this.$http.put("http://localhost:3000/users/"+this.$route.params.id,updateCustomer)
.then(function (response) {
this.$router.push({path: "/", query:{alert: "用户信息修改成功!"}});
});

4. Delete

            this.$http.delete("http://localhost:3000/users/"+id)
.then(function () {
this.$router.push({path: "/", query:{alert:' 用户信息删除成功!'}});
});

5.表单提交

<form v-on:submit="addCustomer">
</form>

6. 无信息就不显示的绑定

<组件v-if="信息" v-bind:message="信息"></组件>

7. 其他界面参数的获取:

this.$route.params.id
//$route对象表示当前的路由信息,包含了当前 URL 解析得到的信息。包含当前的路径,参数,query对象等。

8. e.preventDefault();

//该方法将通知 Web 浏览器不要执行与事件关联的默认动作(如果存在这样的动作)

9. 一般的过滤器

模板:

        <tr v-for="customer in filterBy(customers,filterInput)" :key="customer.id">
<td>{{ customer.name }}</td>
<td>{{ customer.phone }}</td>
<td>{{ customer.email }}</td>
<td><router-link class="btn btn-default" v-bind:to="'/customer/'+customer.id">详情</router-link></td>
</tr>

vue

methods:{
filterBy(customers,value){
return this.customers.filter(function(customer) {
return customer.name.match(value); //按照名字筛选
});
},
},

vue--CRUD的更多相关文章

  1. elementui入门

    1.前端服务器搭建 (1)创建一个static web project (2) 安装 npm install -g vue-cli (3) vue init webpack 项目名 (4)cd 项目名 ...

  2. Build a Basic CRUD App with Vue.js and nodejs

    https://developer.okta.com/blog/2018/02/15/build-crud-app-vuejs-node#add-authentication-with-okta I’ ...

  3. SSM + VUE 实现简单的 CRUD

    一.项目分析 1.需求 (1)使用 ssm + vue 实现一个crud(数据库增删改查)的简单实现.(2)前后端分离,前端页面展示+后台管理. 2.技术点 (1)基础框架: SSM(Spring,S ...

  4. 一起学Vue:CRUD(增删改查)

    目标 使用Vue构建一个非常简单CRUD应用程序,以便您更好地了解它的工作方式. 效果页面 比如我们要实现这样列表.新增.编辑三个页面: 列表页面 新增页面 编辑页面 我们把这些用户信息保存到Todo ...

  5. Vue.js使用-组件示例(实现数据的CRUD)

    1.业务场景 用户(姓名,年龄,性别)的增删改查 2.数据格式 定义字段,name:字段名称,iskey:是否主键(添加,修改数据标志),dataSource:可选列表(下拉框选项) columns: ...

  6. Vue全局过滤器的使用 运用在时间过滤 内容添加crud

    过滤器的使用 msgFormt是你自己定义的过滤器方法, Vue.filter是你自己定义的全局过滤器.没有s 过滤器要有返回值哈 用retuen     Vue.filter("msgFo ...

  7. MVC、MVP、MVVM、Angular.js、Knockout.js、Backbone.js、React.js、Ember.js、Avalon.js、Vue.js 概念摘录

    注:文章内容都是摘录性文字,自己阅读的一些笔记,方便日后查看. MVC MVC(Model-View-Controller),M 是指业务模型,V 是指用户界面,C 则是控制器,使用 MVC 的目的是 ...

  8. SpringBoot vue

    springboot 整合vue就行前后端完全分离,监听器,过滤器,拦截器 https://github.com/ninuxGithub/spring-boot-vue-separateA blog ...

  9. vue,vuex的后台管理项目架子structure-admin,后端服务nodejs

    之前写过一篇vue初始化项目,构建vuex的后台管理项目架子,这个structure-admin-web所拥有的功能 接下来,针对structure-admin-web的不足,进行了补充,开发了具有登 ...

  10. Angular Js 与bootstrap, angular 与 vue.js

    今天突然接到电话, 问我他们的区别  虽然平时看了,但是没记住,凉凉是肯定的 总结一下: bootstrap不算是javascript框架,它只是一个前端的ui框架,然后有一些附带的js插件而已.an ...

随机推荐

  1. “copy” 与 “=“赋值

    前拷贝  与  赋值 >>> a = {1:'one',2:'two',3:'three'}>>> b = a.copy()>>> c = a&g ...

  2. iOS动画浅汇

    转自:http://www.cocoachina.com/ios/20160311/15660.html 在iOS开发中,制作动画效果是最让开发者享受的环节之一.一个设计严谨.精细的动画效果能给用户耳 ...

  3. React Context上下文

    目录 前言 一 context旧版使用步骤 1.1 根组件childContextTypes属性 1.2 根组件getChildContext方法 1.3 子组件contextTypes静态属性 1. ...

  4. ZOJ 2112 Dynamic Rankings(树状数组+主席树)

    The Company Dynamic Rankings has developed a new kind of computer that is no longer satisfied with t ...

  5. ARTS-S c++调用pytorch接口

    想跑通第1个参考资料上讲的例子,一定要注意gcc和gperftools的版本.因为LibTorch用了c++17的over-aligned新特性. centos默认的gcc是4.8.5不支持这个新特性 ...

  6. windows程序设计04_显示汉字的16进制

    看下面的代码 //utf-8编码 #include<stdio.h> int main() { char a[] = "中国"; printf("%x\n&q ...

  7. GlusterFS缺陷

    glusterfs缺陷 转自:http://www.liuwq.com/2017/04/20/glusterfs%E8%AF%A6%E8%A7%A3/ glusterfs 原理.优势.使用范围等 Gl ...

  8. Selenium之显式、隐式等待

    selenium自动化页面元素存在异常发生的原因有以下几点: ① 页面加载时间过慢,需要查找的元素程序已经完成,但是页面还未加载成功.此时可以加载页面等待时间. ② 查找的元素没有在当前的iframe ...

  9. idea实现简单热部署

    首先我们打开设置tomcat的页面         

  10. Redis面试热点工程架构篇之数据同步

    温馨提示 更佳阅读体验:[决战西二旗]|Redis面试热点之工程架构篇[2] 前言 前面用了3篇文章介绍了一些底层实现和工程架构相关的问题,鉴于Redis的热点问题还是比较多的,因此今天继续来看工程架 ...