# 小程序bug

## 1.canvas 自动增加了display:none 属性--OK

增加了canvas-id就会展示了。

## 2. 拖拽延迟

[https://developers.weixin.qq.com/blogdetail?action=get\_post\_info\&docid=000c043a28c2e819bd36628d75b000\&highline=旋转 缩放\&token=1894067750\&lang=zh\_CN](https://developers.weixin.qq.com/blogdetail?action=get_post_info\&docid=000c043a28c2e819bd36628d75b000\&highline=旋转%20缩放\&token=1894067750\&lang=zh_CN)

* 节流函数
* 移动量大于一定值得时候再setData()
* 使用动画API处理

原来这个原因：

```javascript
/**
   * 触摸小配件中
   */
  partTouchMove: function (e) {
    //获取当前小配件的partTouchData
    //let partTouchData = e.currentTarget.dataset.item.partTouchData;
    //获取当前小配件的id
    let id = e.currentTarget.dataset.item.id;
    let partTouchData = this.data.showDogs[id].partTouchData
```

把

```javascript
let partTouchData = e.currentTarget.dataset.item.partTouchData;
```

改为

```javascript
let partTouchData = this.data.showDogs[id].partTouchData
```

完美解决！！！

可能是通过data-绑定了复杂数据，不断循环获取的时候，会严重影响性能。

## 3. Canvas中如果先fill，clip会失效，需求是保存白底图片

因为要用fill画背景颜色，这个时候再剪切的话就会失效。

**解决方法：**

要使保存的canvas背景色是白色，可以在canvasToTempFilePath中加上一个参数， fileType: 'jpg'即可解决。

但是在Android上这样也不行，可以使用异步处理一下就OK了，好像clip和fillRect也不冲突。

```javascript
context.fillStyle = "#fff";
context.fillRect(0, 0, width, height);
```

## 4. Canvas保存的图片像素太低

将目标图片的长和高\*2

参考：<https://www.cnblogs.com/wmhuang/p/6477223.html>

## 5.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://jun-wang.gitbook.io/learnjava/kai-fa/xiao-cheng-xu/xiao-cheng-xu-bug.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
