随笔分类 -  js基础

摘要:一、String() 与 .toString() 的基本介绍 1. String() String() 是一个全局函数,可以将任意类型的值转换为字符串。它不依赖于对象的原型,直接将输入值返回为字符串。 2. .toString() .toString() 是 JavaScript 中几乎所有对象继承 阅读全文
posted @ 2024-12-24 14:10 行走的蒲公英 阅读(54) 评论(0) 推荐(0) 编辑
摘要:js截取字符串中花括号里面的内容,比如json // 用这个方法截取花括号里面的内容。 export function extractJsonFromText(text) { const startIndex = text.indexOf('{'); const endIndex = text.la 阅读全文
posted @ 2024-08-27 10:40 行走的蒲公英 阅读(280) 评论(0) 推荐(0) 编辑
摘要:方法1 /** * 格式化金额 - 数字千分化,保留两位小数 * @param {number | string} num - 输入的数字或字符串 * @returns {string} - 格式化后的金额字符串,空值时返回 '0.00' */ export function numToMoney( 阅读全文
posted @ 2024-07-26 11:46 行走的蒲公英 阅读(236) 评论(0) 推荐(0) 编辑
摘要:1. 获取整个表单: $("#inputForm").serializeArray() 2. 获取单个例如input: $("#input").val() 阅读全文
posted @ 2024-07-01 14:28 行走的蒲公英 阅读(151) 评论(0) 推荐(0) 编辑
摘要:1. 看下效果图 表头为2栏,分为计划、记录; 左侧栏是一天中具体时间点,具体到分钟; 按钮栏分为日周月,三种视图切换: 顶部、左侧固定,都支持滑动滚动条 文本超出,加入鼠标悬浮效果。 2. 用到插件 日历插件fullcalendar :使用v6版本:https://fullcalendar.io/ 阅读全文
posted @ 2024-06-14 16:42 行走的蒲公英 阅读(485) 评论(0) 推荐(0) 编辑
摘要:1. 先看下效果图 这里选用组件:layui的layDate 至今按钮是自定义功能,忽略 2. 官网文档: layui: https://www.bejson.com/doc/layui/doc/index.html layDate: https://www.bejson.com/doc/layui 阅读全文
posted @ 2024-06-14 16:10 行走的蒲公英 阅读(192) 评论(0) 推荐(0) 编辑
摘要:用到element plus 表格,:show-overflow-tooltip="true" 属性在 "element-plus": "2.2.27", 版本不支持修改el-tooltip文本的样式: 满足2点需求:①文字只有一行不显示悬浮框;②超出一行显示省略号,鼠标有悬浮框,且保留文本的换行效 阅读全文
posted @ 2024-03-19 16:10 行走的蒲公英 阅读(1924) 评论(0) 推荐(0) 编辑
摘要:需要用到分页计算: <el-table :data="tableData"> <el-table-column label="序号"> <template #default="{ row, column, $index }"> {{ ($index + 1) + (currentPage - 1) 阅读全文
posted @ 2024-03-18 11:40 行走的蒲公英 阅读(230) 评论(0) 推荐(0) 编辑
摘要:这里记录下,自定义指令相关思路,用到 vue3 + element plus: 说明一下使用场景:创建自定义指令 v-hasPermi , 用来判断按钮权限的(新增/编辑/删除/查看等)。 1. 页面使用(全局使用,无需引入): <el-button type="primary" icon="Plu 阅读全文
posted @ 2024-03-12 15:02 行走的蒲公英 阅读(901) 评论(0) 推荐(0) 编辑
摘要:截取浏览器url function getBowserUrl(path) { let result = ''; if (path) { // 获取当前URL var currentURL = window.location.href; // 使用URL API来解析URL var urlObject 阅读全文
posted @ 2024-03-12 14:08 行走的蒲公英 阅读(8) 评论(0) 推荐(0) 编辑
摘要:1. get请求(参数为对象) 请求地址是,参数用&拼接: 例如:参数格式为一个对象: 请求地址: 请求写法: export function approvalList(data) { return request({ url: '/approval/list', method: 'get', pa 阅读全文
posted @ 2024-03-12 14:01 行走的蒲公英 阅读(203) 评论(0) 推荐(0) 编辑
摘要:function flatFormat(arr, result = []) { for (let i; i < arr.length; i++) { if (Array.isArray(arr[i])) { flatFormat(arr[i], result); } else { result.pu 阅读全文
posted @ 2024-01-30 17:34 行走的蒲公英 阅读(7) 评论(0) 推荐(0) 编辑
摘要:function listToTree(list, parentId = null) { const tree = []; for (let i = 0; i < list.length; i++) { if (list[i].parentId parentId) { const node = { 阅读全文
posted @ 2024-01-30 17:32 行走的蒲公英 阅读(5) 评论(0) 推荐(0) 编辑
摘要:function throttle(func, ms = 1000) { let canRun = true; return function (...args) { if (!canRun) return; canRun = false; setTimeout(() => { func.apply 阅读全文
posted @ 2024-01-30 17:31 行走的蒲公英 阅读(5) 评论(0) 推荐(0) 编辑
摘要:function debounce(func, ms = 1000) { let timer; return function (...args) { if (timer) { clearTimeout(timer); } timer = setTimeout(() => { func.apply( 阅读全文
posted @ 2024-01-30 17:31 行走的蒲公英 阅读(8) 评论(0) 推荐(0) 编辑
摘要:方法一: function format(num) { let str = num + ""; return str .split("") .reverse() .reduce((prev, next, index) => { return (index % 3 ? next : next + ", 阅读全文
posted @ 2024-01-30 17:30 行走的蒲公英 阅读(16) 评论(0) 推荐(0) 编辑
摘要:function newFilter(arr, fn) { let newArr = []; for (let i; i < arr.length; i++) { if (fn(arr[i])) { newArr.push(arr[i]); } } return newArr; } 阅读全文
posted @ 2024-01-30 17:29 行走的蒲公英 阅读(9) 评论(0) 推荐(0) 编辑
摘要:话不多说,上代码 function deepClone(obj) { let newObj = null; if (typeof obj "object") { newObj = obj instanceof Array ? [] : {}; for (let i in obj) { newObj[ 阅读全文
posted @ 2024-01-30 17:28 行走的蒲公英 阅读(5) 评论(0) 推荐(0) 编辑
摘要:在JavaScript中,this 是一个特殊的变量,它引用了调用对象。它的指向在不同的上下文中有不同的变化。以下是一些常见的 this 指向的情况: 1.全局上下文:在全局作用域中,this 指向全局对象。在浏览器中,这通常是 window 对象。 console.log(this); // wi 阅读全文
posted @ 2023-12-27 14:35 行走的蒲公英 阅读(23) 评论(0) 推荐(0) 编辑
摘要:关于文件下载: 1. 贴一下现在项目现有写法: 2. 改进后写法(推荐使用): import { saveAs } from 'file-saver'; saveAs(url,fileName) 3. 其他 (1)同域 <a download=”xxx.xlsx” href="/xxx.xlsx"> 阅读全文
posted @ 2023-02-02 14:49 行走的蒲公英 阅读(454) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示