## Element

<!-- CUSTOMTYPEJSON.Element.description -->

<!-- CUSTOMTYPEJSON.Element.extends -->

<!-- CUSTOMTYPEJSON.Element.param -->

### 方法
<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.name -->

<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.description -->

<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.param -->

<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.getNodeId.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.name -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.description -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.param -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.appendChild.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.name -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.description -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.param -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.insertBefore.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.name -->

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.description -->

**注意**
setAttribute从HBuilderX 3.93起，调整为只能保存string类型属性值，需要保存其它类型数据请使用dataset属性。

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.param -->

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.setAttribute.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.name -->

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.description -->

**注意**
getAttribute返回值从HBuilderX 3.93起，调整为string类型，不要使用此方法获取非string类型的属性值。如有非string需求，请使用对象的点操作符直接访问dateset属性，不通过getAttribute方法。

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.param -->

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.getAttribute.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.name -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.description -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.param -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.hasAttribute.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.name -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.description -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.param -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.removeAttribute.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.name -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.description -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.param -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.getBoundingClientRect.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.name -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.description -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.param -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.getDrawableContext.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.name -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.description -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.param -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.addEventListener.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.name -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.description -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.param -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.removeEventListener.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.name -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.description -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.param -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.removeChild.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.name -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.description -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.param -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.remove.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.name -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.description -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.param -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.dispatchEvent.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.name -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.description -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.param -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollTo.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.name -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.description -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.param -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.scrollBy.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.name -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.description -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.param -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.focus.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.name -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.description -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.param -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.blur.tutorial -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.name -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.description -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.param -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.returnValue -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.compatibility -->

<!-- CUSTOMTYPEJSON.Element.methods.takeSnapshot.tutorial -->


```ts
// 找到需要截图节点
const view = uni.getElementById('snapshot-content')!
// 进行截图
view.takeSnapshot({
    success: function (res) {
        // 打印截图文件临时路径
        console.log(res.tempFilePath)
        uni.showToast({
            title: '截图成功，路径：' + res.tempFilePath,
            icon: "none"
        })
    },
    fail: function (res) {
        console.log(res)
        uni.showToast({
            icon: 'error',
            title: '截图失败'
        })
    }
})
```

完整示例代码参考[hello uni-app x](https://gitcode.net/dcloud/hello-uni-app-x/-/blob/alpha/pages/API/element-takesnapshot/element-takesnapshot.uvue)
