• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
技术杨的博客园
希望每一次的努力都能得到自己想要的
博客园    首页    新随笔    联系   管理    订阅  订阅
2023年1月29日
vue中多行(单行)文本溢出才会出现提示的自定义指令
摘要: // 以下代码可以直接粘贴进自己的`.vue`文件中查看效果 <template> <div class="parent"> <h3>标题</h3> <div class="child" v-ellipsis="3"> {{ msg }} </div> </div> </template> <scr 阅读全文
posted @ 2023-01-29 17:59 技术杨 阅读(340) 评论(0) 推荐(0)
生产环境去除 console.log
摘要: vue.config.js 中配置 configureWebpack: (config) => { if (process.env.NODE_ENV "production") { config.optimization.minimizer[0].options.terserOptions.comp 阅读全文
posted @ 2023-01-29 17:40 技术杨 阅读(107) 评论(0) 推荐(0)
开发中用到定时器时我们一般这样
摘要: // bad mounted() { // 创建一个定时器 this.timer = setInterval(() => { // ...... }, 500); }, // 销毁这个定时器。 beforeDestroy() { if (this.timer) { clearInterval(thi 阅读全文
posted @ 2023-01-29 17:27 技术杨 阅读(21) 评论(0) 推荐(0)
iframe框架内页面控制父框架页面跳转到某地址
摘要: const { href } = this.$router.resolve({ path: "/index", query: { key: key } }); // iframe 控制父页面跳转 window.parent.window.location.href = href 阅读全文
posted @ 2023-01-29 17:25 技术杨 阅读(38) 评论(0) 推荐(0)
解析URL参数
摘要: export const getSearchParams = () => { const searchPar = new URLSearchParams(window.location.search) const paramsObj = {} for (const [key, value] of s 阅读全文
posted @ 2023-01-29 17:17 技术杨 阅读(50) 评论(0) 推荐(0)
大小写转换
摘要: 参数: str 待转换的字符串 type 1-全大写 2-全小写 3-首字母大写 export const turnCase = (str, type) => { switch (type) { case 1: return str.toUpperCase() case 2: return str. 阅读全文
posted @ 2023-01-29 17:16 技术杨 阅读(48) 评论(0) 推荐(0)
校验数据类型
摘要: export const typeOf = function(obj) { return Object.prototype.toString.call(obj).slice(8, -1).toLowerCase() } 示例: typeOf('树哥') // string typeOf([]) // 阅读全文
posted @ 2023-01-29 17:15 技术杨 阅读(19) 评论(0) 推荐(0)
防抖
摘要: export const debounce = (() => { let timer = null return (callback, wait = 800) => { timer&&clearTimeout(timer) timer = setTimeout(callback, wait) } } 阅读全文
posted @ 2023-01-29 17:14 技术杨 阅读(55) 评论(0) 推荐(0)
遍历树节点
摘要: export const foreachTree = (data, callback, childrenName = 'children') => { for (let i = 0; i < data.length; i++) { callback(data[i]) if (data[i][chil 阅读全文
posted @ 2023-01-29 17:11 技术杨 阅读(19) 评论(0) 推荐(0)
模糊搜索
摘要: 参数: list 原数组 keyWord 查询的关键词 attribute 数组需要检索属性 export const fuzzyQuery = (list, keyWord, attribute = 'name') => { const reg = new RegExp(keyWord) cons 阅读全文
posted @ 2023-01-29 17:10 技术杨 阅读(134) 评论(0) 推荐(0)
下载文件
摘要: 参数: api 接口 params 请求参数 fileName 文件名 const downloadFile = (api, params, fileName, type = 'get') => { axios({ method: type, url: api, responseType: 'blo 阅读全文
posted @ 2023-01-29 17:06 技术杨 阅读(203) 评论(0) 推荐(0)
存储操作
摘要: class MyCache { constructor(isLocal = true) { this.storage = isLocal ? localStorage : sessionStorage } setItem(key, value) { if (typeof (value) 'objec 阅读全文
posted @ 2023-01-29 17:03 技术杨 阅读(21) 评论(0) 推荐(0)
金额格式化
摘要: 参数: {number} number:要格式化的数字 {number} decimals:保留几位小数 {string} dec_point:小数点符号 {string} thousands_sep:千分位符号 export const moneyFormat = (number, decimal 阅读全文
posted @ 2023-01-29 17:02 技术杨 阅读(88) 评论(0) 推荐(0)
前端生产id,uuid
摘要: export const uuid = () => { const temp_url = URL.createObjectURL(new Blob()) const uuid = temp_url.toString() URL.revokeObjectURL(temp_url) //释放这个url 阅读全文
posted @ 2023-01-29 17:00 技术杨 阅读(126) 评论(0) 推荐(0)
滚动到元素位置
摘要: export const smoothScroll = element =>{ document.querySelector(element).scrollIntoView({ behavior: 'smooth' }); }; 示例: smoothScroll('#target'); // 平滑滚 阅读全文
posted @ 2023-01-29 16:59 技术杨 阅读(50) 评论(0) 推荐(0)
数组去重
摘要: 用 Set 数据结构 对于对象数组,可以使用 Set 数据结构对其中的对象进行去重。代码如下: let arr = [{name: 'apple'}, {name: 'orange'}, {name: 'apple'}]; let newArr = Array.from(new Set(arr.ma 阅读全文
posted @ 2023-01-29 16:56 技术杨 阅读(48) 评论(0) 推荐(0)
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3