有的東西看完立刻就忘,收藏的文章也歷來沒有回頭看過,試試本身寫一個!!!!但願能夠堅持,之後把遇到的插件/工具記錄在這裏,若是有哪裏錯了(我這個小垃圾確定會出錯啊!!!!!!),請你們幫我指出,最後但願這個記錄能夠堅持下去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