Signature (签名)
创建签名区域的组件,支持多种配置,包括线条颜色、大小、平滑模式等。
支持平台
安卓 | ios | 鸿蒙 | web | 微信小程序 |
---|---|---|---|---|
√ | √ | √ | √ | √ |
示例代码
html
<template>
<t-page :scrollDisabled="true" main-class="twh-100% dr">
<t-signature main-class="twh-100% bg-#F6F0DE" ref="signatures" type="p" :lineSize="3"></t-signature>
<t-button main-class="da atr-90 mt-60" type="error" @click="quit">退出</t-button>
<t-row main-class="da db-30 dl-n270 atr-90 mb-280">
<t-button main-class="mr-30" type="error" @click="clear">清空</t-button>
<t-button main-class="mr-30" type="warning" @click="undo">撤消</t-button>
<t-button main-class="mr-30" type="success" @click="redo">恢复</t-button>
<t-button main-class="mr-30" type="primary" @click="save">确定</t-button>
</t-row>
</t-page>
</template>
<script>
export default {
data() {
return {
signEl: null as TSignatureComponentPublicInstance | null
}
},
methods: {
quit() {
uni.navigateBack()
},
clear() {
const sign = this.signEl as TSignatureComponentPublicInstance
sign.clear()
},
undo() {
const sign = this.signEl as TSignatureComponentPublicInstance
sign.undo()
},
redo() {
const sign = this.signEl as TSignatureComponentPublicInstance
sign.redo()
},
save() {
const sign = this.signEl as TSignatureComponentPublicInstance
sign.save().then((res : string) => {
uni.previewImage({ urls: [res] })
})
}
},
mounted() {
this.signEl = this.$refs['signatures'] as TSignatureComponentPublicInstance
}
}
</script>
属性
名称 | 类型 | 默认值 | 说明 | 可选值 |
---|---|---|---|---|
size | String | mini | 组件尺寸 | large(大尺寸), medium(中尺寸), small(小尺寸), mini(迷你) |
type | String | "" | 组件类型 | info(信息), primary(正常), error(错误), warning(警告), success(成功) |
disabled | Boolean | false | 组件是否禁用 | false, true |
stop | Boolean | false | 是否阻止事件冒泡(Tui统一写法处理事件冒泡) | false, true |
hover | Boolean | true | 是否有点击效果 | false, true |
path | String | "" | 点击组件后跳转的页面路径,如果为空则响应点击事件,如果不为空则跳转页面不会响应单击事件。 | - |
mainClass | String | "" | 组件根节点的样式 | - |
nativeClass | String | "" | 组件根节点原生样式 | - |
effect | String | "normal" | 组件显示主题 | normal(正常), dark(深色), light(浅色), plain(镂空) |
lineSize | Number | 2 | 线条大小 | |
color | String | `` | 线条颜色 | |
maxHistory | Number | 20 | 最大历史记录点数 |
方法
名称 | 参数 | 返回值 | 说明 |
---|---|---|---|
redo | - | - | 重置上一步操作 |
save | - | - | 保存签名 |
clear | - | - | 清空签名区域 |
undo | - | - | 撤销上一步操作 |