技术杂谈

prettier格式化时避免删除无用引用

项目中为了保证import的内容按照一定的顺序进行排序,prettier中会引入prettier-plugin-organize-imports插件。但是此插件的默认行为会将引入但是没有使用的包在保存时直接删除掉,查询文档发现为了规避这种破坏性更改需要增加一条配置"organizeImportsSkipDestructiveCodeActions": true, 完整的.prettierrc配置内容为 { "printWidth": 100, "singleQuote": true, "trailingComma": "all", "proseWrap": "never", "Semicolons": true, "organizeImportsSkipDestructiveCodeActions": true, ...

audio标签

动态替换播放地址 //替换完成后,先执行load方法 document.getElementById('playaudio').load(); 监听播放完成 document.getElementById('playaudio').addEventListener('ended',function(){ console.log('over'); that.playing = false; ...

总结

1. 矩形图片显示中间部分 .panel{ height: 200px; width: 200px; background-size: cover; background-position: center; background-image: url('./img1.png'); }

1.1 补充: 使用object-fit ...