新聞中心
- canvas 畫布
- 屬性說明
- 示例
- 代碼示例
- Bug & Tip
canvas 畫布
基礎庫版本 1.12.0 開始支持事件捕獲、冒泡。
網站建設哪家好,找創(chuàng)新互聯(lián)建站!專注于網頁設計、網站建設、微信開發(fā)、重慶小程序開發(fā)、集團企業(yè)網站建設等服務項目。為回饋新老客戶創(chuàng)新互聯(lián)還提供了寶安免費建站歡迎大家使用!
解釋:畫布。畫布是一個矩形區(qū)域(默認寬度 300px、高度 225px ),開發(fā)者可以在頁面上繪制圖形。canvas 擁有多種繪制路徑、矩形、圖形、字符以及添加圖像的方法。相關 API:swan.createCanvasContext 該組件是客戶端創(chuàng)建的原生組件,使用時請注意相關限制。
屬性說明
| 屬性名 | 類型 | 默認值 | 必填 | 說明 |
|---|---|---|---|---|
canvas-id | String | 是 | canvas 組件的唯一標識符 | |
disable-scroll | Boolean | false | 否 | 當在 canvas 中移動且有綁定手勢事件時,禁止屏幕滾動以及下拉刷新 |
bindtouchstart | EventHandle | 否 | 手指觸摸動作開始 | |
bindtouchmove | EventHandle | 否 | 手指觸摸后移動 | |
bindtouchend | EventHandle | 否 | 手指觸摸動作結束 | |
bindtouchcancel | EventHandle | 否 | 手指觸摸動作被打斷,如來電提醒,彈窗 | |
bindlongtap | EventHandle | 否 | 手指長按 350ms 之后觸發(fā),觸發(fā)了長按事件后進行移動不會觸發(fā)屏幕的滾動 | |
binderror | EventHandle | 否 | 當發(fā)生錯誤時觸發(fā) error 事件,detail = {errMsg: ‘something wrong’} |
示例
跳轉編輯工具
在開發(fā)者工具中打開
在 WEB IDE 中打開
掃碼體驗
代碼示例
請使用百度APP掃碼
代碼示例
- SWAN
- JS
- CSS
canvas-id="mycanvas"disable-scroll="false"bindtouchstart="touchstart"bindtouchmove="touchmove"bindtouchend="touchend"bindtouchcancel="touchcancel"bindlongtap="longtap"binderror="error">{{resultComment}}
Bug & Tip
- Tip:canvas 組件不能使用動畫進行控制。
新聞標題:創(chuàng)新互聯(lián)百度小程序教程:canvas畫布
網頁路徑:http://www.fisionsoft.com.cn/article/cdsoesd.html


咨詢
建站咨詢

