07 2021 档案

摘要:最常见的props传值 父组件在调用子组件的时候将值一并写入,子组件在父组件中通过props接收值。 父组件传值: <template> <div> 父组件 <Child :msg="msg"></Child> </div> </template> <script> import Child fro 阅读全文
posted @ 2021-07-24 19:24 孤城牧笛 阅读(60) 评论(0) 推荐(0)
摘要:问题描述 在Menu导航栏中选中菜单栏,在刷新页面后,菜单仍然是选中状态 菜单的index值为路由导航地址,通过sessionStorage将当前选中的地址保存起来,实现效果。 setSelectPath(path){ window.sessionStorage.setItem('selectPat 阅读全文
posted @ 2021-07-22 12:20 孤城牧笛 阅读(272) 评论(0) 推荐(0)
摘要:return sKey void 0?obj:obj[sKey]||'' void 0 undefined 判断为true 上式判断函数中是否传入了sKey参数,如果传入了取后值,未传入取前值 ??是合并运算符,当值不为undefined和null时,取前值,否则去后值 a=a??'hello' 阅读全文
posted @ 2021-07-11 15:21 孤城牧笛 阅读(95) 评论(0) 推荐(0)
摘要:charAt() 用户获得字符串中指定下标的字符 s='abcdef' console.log(s.charAt(0)) //a 注意:只能读,不能写 s='abcdef' s.charAt(0)='c' console.log(s) 运行结果 现在能想到的修改字符串中某个字符的方式就是将字符串转为 阅读全文
posted @ 2021-07-03 13:32 孤城牧笛 阅读(621) 评论(0) 推荐(0)
摘要:问题 使用Array.sort()方法对数组中的元素进行排序 let arr=[10,2,10,10,10,10,8,2,7,8] arr.sort() console.log(arr) // [ // 10, 10, 10, 10, 10, // 2, 2, 7, 8, 8 // ] 输出结果未实 阅读全文
posted @ 2021-07-03 12:24 孤城牧笛 阅读(187) 评论(0) 推荐(0)
摘要:描述 使用JSON.parse(window.localStorage.getItem(TASKKEY)||'[]')获取缓存中的数据时,遇到了以下问题 分析 经过求证发现JSON.parse(undefined)会报此类错误,可是在上述代码中用**||**规避了window.localStorag 阅读全文
posted @ 2021-07-02 21:50 孤城牧笛 阅读(2979) 评论(0) 推荐(0)
摘要:问题描述 在以下目录结构的index.html文件中引入css中的文件,发现页面并未生效 解决方式 将css文件放入static文件再引入,样式生效了 不过这是为什么呢??? 阅读全文
posted @ 2021-07-02 15:16 孤城牧笛 阅读(659) 评论(0) 推荐(0)