流浪のwolf

卷帝

导航

上一页 1 ··· 57 58 59 60 61 62 63 64 65 ··· 73 下一页

2022年10月13日

vant2 List 组件 下拉加载 onLoad

摘要: ps:loading finished onLoad 两个变量一个函数 ; async onLoad() { console.log("onload"); // 异步更新数据 // setTimeout 仅做示例,真实场景中一般为 ajax 请求 // 加载状态结束 this.page += 1; 阅读全文

posted @ 2022-10-13 19:30 流浪のwolf 阅读(31) 评论(0) 推荐(0) 编辑

回车搜索和点击建议搜索复用一个函数

摘要: 标签里面的事件(子组件传参emit) 优先级大于methods的事件方法 ; ps:取消奥按钮:@cancel="$router.go(-1)" 子组件传参: @click="$emit('search', item)" 回车请求数据 : @search="onSearch(keywords)" ; 阅读全文

posted @ 2022-10-13 17:24 流浪のwolf 阅读(18) 评论(0) 推荐(0) 编辑

watch 监视搜索关键词的变化不断发送请求返回建议

摘要: watch: { keywords: { // yarn add lodash 下载lodash包 // import { debounce } from "lodash"; 引入防抖的函数 // 每隔700ms执行一次handler函数(在keywords变化的情况下,频繁触发的事件) handl 阅读全文

posted @ 2022-10-13 16:54 流浪のwolf 阅读(14) 评论(0) 推荐(0) 编辑

搜索显示建议内容时显示具体搜索内容高亮

摘要: <span v-html="hightLight(item)"></span> 思路:匹配出搜索的关键词然后替换为高亮的标签 ; hightLight(str) { // 搜索高亮 const reg = new RegExp(this.keywords, "gi"); console.log(re 阅读全文

posted @ 2022-10-13 15:57 流浪のwolf 阅读(9) 评论(0) 推荐(0) 编辑

搜索历史、建议、结果的显示逻辑

摘要: <template> <div id="searchVue"> <form action="/"> <van-search v-model="keywords" show-action background="#4694fa" placeholder="请输入搜索关键词" @search="onSe 阅读全文

posted @ 2022-10-13 11:52 流浪のwolf 阅读(20) 评论(0) 推荐(0) 编辑

2022年10月11日

封装setItem 和 getItem 本地存储

摘要: store.js 文件 按需导出setItem 和 getItem 函数 ;在utils文件里面 ; export const setItem = (key, value) => { // 复杂数据需要序列化 if (typeof value "object") { localStorage.set 阅读全文

posted @ 2022-10-11 15:40 流浪のwolf 阅读(54) 评论(0) 推荐(0) 编辑

yarn serve 不能开启vue项目 the project seem to require yarn but isnot install

摘要: error: answer: 删除 yarn.lock 或者使用 npm run serve 替换 ; ps: yarn.lock 是锁定第三方包版本的文件; 阅读全文

posted @ 2022-10-11 11:09 流浪のwolf 阅读(24) 评论(0) 推荐(0) 编辑

vant 2 的 toast

摘要: 因为toast使用的场景比较频繁,所以在 注册使用 Toast 的时候,直接在Vue实列的原型上添加了toast方便我们使用 ; 格式:this.$toast.fail() this.$toast.success() ; 阅读全文

posted @ 2022-10-11 11:00 流浪のwolf 阅读(30) 评论(0) 推荐(0) 编辑

统一携带 token

摘要: tokne 可以使用 vuex 和 本地存储处理 ; 一些接口需要携带token为了避免代码的重复性,可以在请求拦截器统一加入token ,每次请求都会携带token参数,不需要token参数的接口也不会受到影响,因为服务器只会监测自己所需要的参数 ; // 添加请求拦截器 request.inte 阅读全文

posted @ 2022-10-11 10:58 流浪のwolf 阅读(202) 评论(0) 推荐(0) 编辑

我的频道 推荐频道 和全部频道之间的关系

摘要: 推荐频道 = 全部频道 - 我的频道 ; 实现的页面: 计算出推荐频道 :筛选全部频道每一项 ,和我的频道的每一项比较,如果有相同的数据,说明不是推荐数据,要筛选掉,some是只要有一个为真就返回true然后取反false 就实现了筛选; computed: { recommendChannels( 阅读全文

posted @ 2022-10-11 10:48 流浪のwolf 阅读(352) 评论(0) 推荐(0) 编辑

上一页 1 ··· 57 58 59 60 61 62 63 64 65 ··· 73 下一页