有的东西看完立刻就忘,收藏的文章也历来没有回头看过,试试本身写一个!!!!但愿能够坚持,之后把遇到的插件/工具记录在这里,若是有哪里错了(我这个小垃圾确定会出错啊!!!!!!),请你们帮我指出,最后但愿这个记录能够坚持下去html
含义:是一个处理日期和事件的插件前端
使用:node
npm i moment
......
//下面注册一个全局的过滤器
Vue.filter('msg1',(res,data)=>{
return moment(res).format(data)
})
......
//使用msg1这个过滤器(这里假设vm实例的data中有data1这个数据)
<div id="app">
<!--在msg1中传了参数YYYY,表示将日期处理成只显示年份--> <div>{{data1|msg1("YYYY")}}</div> </div>
复制代码
含义 提供假数据==>根据一个
.json
文件生成一个接口 使用步骤ios
npm run json-server -g
全局安装当成一个工具使用json-server 文件名
生成接口get
post
delete
put/patch
----------------听说前端更欢喜后者然后端更喜欢前者注意:put
和patch
的区别: PUT
须要提供该对象的全部数据PATCH
只须要提供要修改的数据便可git
由于不清楚
REST API
稍微百度了一下REST API的使用
github
能够借助
postman
测试接口ajax
含义: 这是一个基于
Promise
的请求工具库,封装了ajax,用来发送请求,异步获取数据 适用于浏览器
和node
npm
npm i axios
axios
//发送get请求全部数据
//axios.get("请求地址",()=>{})
axios.get('http://localhost:3000/list').then(res => {
console.log(res);
})
//请求具体的数据
//方式1...直接/后面跟着id
axios.get('http://localhost:3000/list/1').then(res => {
console.log(res);
})
//方式2 ...在地址后传一个对象
axios.get('http://localhost:3000/list',{ params: {id: 1}}).then(res => {
console.log(res);
})
<!--分割线-->
//发送post请求,添加数据
//注意不用指定id会自动追加
axios.post('http://localhost:3000/list',{name:"小仙女",done:"false"}).then(res => {
console.log(res);
})
<!--分割线-->
//发送delete删除请求
//在路径后凭借要删除的数据的id
//注意 状态码为200 不表明就成功了 还要确认一下`data`的答应结果是否为空
axios.delete('http://localhost:3000/list/1').then(res => {
console.log(res);
})
<!--分割线-->
//更改数据
//哈哈哈~~patch比较方便啊
//拼接要修改数据的id,和须要修该的属性和值
axios.patch('http://localhost:3000/list/1',{name:"老仙女"}).then(res => {
console.log(res);
})
//put
//拼接要修改的数据的id和须要提供该对象的全部数据
axios.put('http://localhost:3000/list/1',{name:"老仙女",done:'false'}).then(res => {
console.log(res);
})
复制代码
----------------------等待更新的分割线,若有错误欢迎指正------------------------------------json