**文字換行**
CanvasRenderingContext2D.prototype.wrapText \= function (text, x, y, maxWidth, lineHeight) {
if (typeof text != 'string' || typeof x != 'number' || typeof y != 'number') {
return;
}
var context \= this;
var canvas \= context.canvas;
if (typeof maxWidth \== 'undefined') {
maxWidth \= (canvas && canvas.width) || 300;
}
if (typeof lineHeight \== 'undefined') {
lineHeight \= (canvas && parseInt(window.getComputedStyle(canvas).lineHeight)) || parseInt(window.getComputedStyle(document.body).lineHeight);
}
// 字符分隔為數組
var arrText \= text.split('');
var line \= '';
for (var n \= 0; n < arrText.length; n++) {
var testLine \= line + arrText\[n\];
var metrics \= context.measureText(testLine);
var testWidth \= metrics.width;
if (testWidth \> maxWidth && n \> 0) {
context.fillText(line, x, y);
line \= arrText\[n\];
y += lineHeight;
} else {
line \= testLine;
}
}
context.fillText(line, x, y);
};
- CSS
- 長度單位
- 問題們
- 背景漸變
- 禁止用戶選中
- 給富文本重置樣式
- 移動端常見小問題
- bfc
- flex
- 父元素沒有包裹子元素的margin
- VUE
- 原理
- 生命周期
- vue-router原理
- 動態修改路由參數
- 在新窗口打開頁面
- 連跳兩個頁面
- 跳轉頁面自動回到頂部
- vue+webpack項目,停留一段時間報錯
- vue 路由去掉#
- webpack編譯目錄設置
- config配置
- HTTP
- HTTP狀態碼
- HTTP1.0,HTTP1.1,HTTP2.0
- axios和ajax的區別
- 模塊化
- git
- 比較
- 查看遠程倉庫地址
- git flow
- 比較分支的不同并保存壓縮文件
- Tag
- 回退
- node版本管理
- npm
- 確定用戶是否在當前頁面
- 前端下載文件
- 只能在微信中訪問
- 下載圖片
- webpack修改路徑為相對路徑
- 打開新頁面-被瀏覽器攔截
- textarea高度隨內容變化
- Debian/Ubuntu 安裝shadowsock
- 垂直居中
- video
- 去掉ios原始播放大按鈕
- 前端直播
- ios系列
- js彈出錯誤代碼
- nginx在MAC上的安裝、啟動、重啟和關閉
- 解析latex格式的數學公式
- Mac 新建unix可執行文件
- 正則-格式化a鏈接
- 原型
- unicode解析
- vue+webpack打包優化
- 各種JS題
- ES6
- seo
- React
- 兼容性
- canvas
- zsh