Arki 的每日 BUG 观察
41 subscribers
78 photos
1 video
3 files
228 links
分享每天写的bug
以前端为主
Download Telegram
大家对这个频道有什么意见建议,消息存在错误甚至想要搭讪,都欢迎通过 [google forms](https://forms.gle/jUknwjNmG9EaNDtJ8) 联系我(支持匿名)
Arki 的每日 BUG 观察 pinned «大家对这个频道有什么意见建议,消息存在错误甚至想要搭讪,都欢迎通过 [google forms](https://forms.gle/jUknwjNmG9EaNDtJ8) 联系我(支持匿名)»
#bash

# 如果存在 build 目录就删除该目录
if [ -d build ]; then
rm -rf build; # 结尾分号!!
fi
平时 bash 写的少,这种必须写分号的地方没写结果报错又找不到哪错QAQ
#git
如何将某个 dist 文件夹单独部署 gh-pages 分支?

大部分人可能重新建个git仓库push
cd dist
git init
git add .
git commit -m 'Deploy'
git remote add upstream [Upstream git URL]
git push origin gh-pages

实际上,使用 subtree 这个稀有命令更方便更优雅

git subtree split --prefix dist -b gh-pages # create a local gh-pages branch containing the splitted output folder
git push -f origin gh-pages:gh-pages # force the push of the gh-pages branch to the remote gh-pages branch at origin
git branch -D gh-pages

参考 [Deploying a subfolder to GitHub Pages](https://gist.github.com/cobyism/4730490)
* 该方案未亲自测试,如果有人踩坑请务必告知
#java
函数式的方法处理 null list
···
list = Optional.ofNull(list).orElse(Collecitons.emplyList())
···
#js
str.replace('abc', '') 不是全部替换!!默认只替换第一个
repalceAll 请使用正则表达式
str.replace(/abc/g, '')
#html
ol/ul > li 会自动缩进,并且由于 ol 会自动添上 list 的 marker ,单纯使用 padding-left 取消缩进会发现 list 的 marker 位置不对了
正确的取消缩进的方法除了修改 padding-left 为 0 之外还需要使用 css list-style-position: outside; 调整 marker 位置

关于 list-style-position 这个 css 可以看这里
https://developer.mozilla.org/en-US/docs/Web/CSS/list-style-position
不使用 list-style-position 时
使用 list-style-position: inside;
Forwarded from Haruki Kirigaya [Alter]
#小程序

我讨厌微信小程序的一个原因就是你永远也不知道你回遇到什么样的 BUG

微信小程序 background 透明度 BUG
/* 微信开发工具预览正常 Iphone 正常 Android 不正常 可能和基础库版本有关系 */
background: #00000080

/* 解决方案 使用 rgba 的形式表示 */
background: rgba(0, 0, 0, 0.5);

解决方案 使用 rgba 的形式表示????
新增了评论 bot,可以方便地评论了
#小程序

父组件如何调用子组件的方法?

通过 this.selectComponent 方法获取子组件实例对象,这样就可以直接访问组件的任意数据和方法

具体操作方式如下
<!-- index.xtml -->
<com id="child" />

// index.js
const child = this.selectComponent('#child')
child.go()
#js
如何判断一个变量是 null or undefined
if ( some_variable == null ){
// some_variable is either null or undefined
}

这么做比分别判断简单多了
#js

safari 的 date 解析和 chrome 相比有很多种格式不支持

// safari
new Date('2000-04-12 00:00:00 GMT+0000')
// Invalid Date

// chrome
new Date('2000-04-12 00:00:00 GMT+0000')
Wed Apr 12 2000 00:00:00 GMT+0000


简单粗暴的解决方案
new Date('2000-04-12 00:00:00 GMT+0000'.replace(/-/g, '/'))


[Invalid date in safari
](https://stackoverflow.com/questions/4310953/invalid-date-in-safari)
#js

某位前辈在网络请求的 Promise 处理玩异常后直接 return 结束了函数,没有 reject 异常。。

结果就是这个 Promise 一直处于 pending 状态,无论使用 catch 还是 finally 都无法继续执行,及其坑爹。。