摘要:传值 keywords <template> <van-list v-model="loading" :finished="finished" finished-text="没有更多了" @load="onLoad" > <van-cell v-for="(item, index) in list"
阅读全文
摘要:// 父组件传 1 个值 关键词 // 子组件 的 emit自定义的search事件会委托父组件改变 keywords 的值 然后更新 props 的keywords 然会触发 watch 的 handler 函数 然后请求建议数据 <template> <div> <!-- 显示搜索建议 -->
阅读全文
摘要:搜索逻辑的判断展示思路 * 1. 如果 keywords 是空,就显示搜索历史 * 2. 如果 input 聚焦,并且搜索关键词 keywords 不为空,就显示搜索建议 * 3. 点击搜索按钮或者在input框聚焦状态下按下 enter 触发 input 的时候展示搜索结果 <form actio
阅读全文
摘要:// vue.config.js 文件是脚手架的配置文件 const { defineConfig } = require("@vue/cli-service"); module.exports = defineConfig({ transpileDependencies: true, lintOn
阅读全文
摘要:1. vue create 项目名称 整理目录 2. 工具层 utils 封装本地存储 storage.js 存值 取值 删值 封装请求实例 request.js 创建实例 - 配置基准地址 baseURL 请求拦截器 - 统一携带 token 响应拦截器 - 处理 token 过期 未登录 异常错
阅读全文
摘要:场景:token过期,然后更新了token 重新发起请求获取数据 ; 代码:使用上一次的错误请求配置报错 return request(error.config) ; 解决 : return request({ ...error.config, headers: {}, }); // 添加响应拦截器
阅读全文
摘要:1. 添加全局前置路由守卫 import store from "@/store"; import Vue from "vue"; import VueRouter from "vue-router"; Vue.use(VueRouter); const routes = [ { path: "/"
阅读全文
摘要:使用场景:点击图片预览图片的时候,用于生成一个临时的预览地址 ,会存放在本地电脑的内存中 ; imgFile 是?? 使用 input type = file 选择的图片 ; const imgFile = this.$refs.imgFile.files[0]; // 接口需要的参数 file类型
阅读全文
摘要:点击生日表格的时候,popoup 显示 ,popup 包裹一个修改生日的组件 ; ps:父组件传值 当前的 日期 birthday -currentDate ; 在onfirm 方法里面更新数据 ,然后更新视图 ; <template> <van-datetime-picker v-model="c
阅读全文
摘要:console.log(this.currentDate); // Sat Dec 22 2007 00:00:00 GMT+0800 (中国标准时间) const str = dayjs(this.currentDate).format("YYYY-MM-DD"); console.log(str
阅读全文
摘要:v-model 的使用 解决只能使用一次v-model的问题:使用 sync 修饰符
阅读全文
摘要:组件没有销毁,点击取消的时候把UpdateName组件销毁即可:即加上 v-if 即可 ;
阅读全文
摘要:<template> <div class="update-name"> <!-- 导航栏 --> <van-nav-bar title="设置昵称" left-text="取消" right-text="完成" @click-left="$emit('close')" /> <!-- /导航栏 -
阅读全文
摘要:1 <template> 2 <div class="user-profile"> 3 <!-- 导航栏 --> 4 <van-nav-bar 5 class="page-nav-bar" 6 title="个人信息" 7 left-arrow 8 @click-left="$router.back
阅读全文
摘要:说明:上传的图片是 file 类型 ,核心就是获取图片文件(file类型的) ; 实现一:使用 vant2 的图片加载组件 ,选择文件后会触发afterRead方法 ,参数 file 就是文件列表filelist ,file.file 就是图片文件 ; async afterRead(file) {
阅读全文
摘要:ref 给 <van-form @submit="onSubmit" ref="form"> 标签 ; // 检验手机号是否合格 await this.$refs.form.validate("mobile"); data里面定义的规则 rules对象 ; rules: { mobile: [ //
阅读全文