This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## Vue3 里 script | |
Vue3 新增了一个叫做组合式 api 的东西,英文名叫 Composition API | |
### setup() | |
```javascript | |
<template> | |
<div>{{ count }}</div> | |
<button @click="onClick"> | |
增加 1 | |
</button> | |
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
|key|keycode|功能| | |
|-|-|-| | |
|F8|119 |开启/关闭导航| | |
|F9|120|预览/编辑切换| | |
|F10 |121 |开启/关闭全屏| | |
|F11 |122 |开启/关闭阅读模式| | |
|F12 |123 |单栏/双栏切换| | |
|TAB |9 |缩进| | |
|CTRL + S |17 + 83 |触发保存| | |
|CTRL + D |17 + 68 |删除选中行| |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 重排 重绘 | |
1. 最小化重绘和重排,比如样式集中改变,使用添加新样式类名 .class 或 cssText 。 | |
2. 批量操作 DOM,比如读取某元素 offsetWidth 属性存到一个临时变量,再去使用,而不是频繁使用这个计算属性;又比如利用 document.createDocumentFragment() 来添加要被添加的节点,处理完之后再插入到实际 DOM 中。 | |
3. 使用 **absolute** 或 **fixed** 使元素脱离文档流,这在制作复杂的动画时对性能的影响比较明显。 | |
4. 开启 GPU 加速,利用 css 属性 transform 、will-change 等,比如改变元素位置,我们使用 translate 会比使用绝对定位改变其 left 、top 等来的高效,因为它不会触发重排或重绘,transform 使浏览器为元素创建⼀个 GPU 图层,这使得动画元素在一个独立的层中进行渲染。当元素的内容没有发生改变,就没有必要进行重绘。 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 关于一位数补0 | |
```javascript | |
var n = 9; | |
('0'+n).slice(-2);//"09" | |
var n = 19; | |
('0'+n).slice(-2)//"19" | |
//未知兼容性 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 苹果键盘顶上内容不下来/安卓input被遮住(input框) | |
```javascript | |
内容1屏 | |
if(isAndroid){ | |
var winHeight = $(window).height(); //获取当前页面高度 | |
$(window).resize(function() { | |
var thisHeight = $(this).height(); | |
if (winHeight - thisHeight > 50) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 使用 .test() 方法 | |
```javascript | |
let testString = "My test string"; | |
let testRegex = /string/; | |
testRegex.test(testString); | |
``` | |
### 匹配多个模式 (使用操作符号 |) | |
```javascript | |
const regex = /yes|no|maybe/; | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 父页面调用子页面的方法 | |
```language | |
function test(){ alert("test"); } | |
子页面的方法 | |
function childtest(){ window.parent.test(); } | |
``` | |
### 小程序封装 | |
```javascript:; | |
//app.js | |
App({ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 一句js默认给所有元素加上边框调试 | |
```javascript | |
[].forEach.call($("*"),function(a){ a.style.outline="1px solid #"+(~~(Math.random()*(1<<24))).toString(16) }); | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 谷歌配置跨域调试 | |
```language | |
在google快捷方式属性 目标后面加上 | |
--user-data-dir="c:\ChromeDebug" --test-type --disable-web-security | |
``` | |
### webstorm配置svn | |
```language | |
plugins 搜索svn install svntoolbox | |
然后restart | |
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
### 1.单页面应用上传到服务器后刷新出现404的问题 | |
```language | |
//nginx保证2点就行: | |
1.刷新时要保证url路径不变。。。言外之意就是不能用重定向去访问index.html,因为url会变。变了js框架就没法路由。因为不知道你上次是哪个url了。。。 | |
NewerOlder