Signature
组件类型:UxSignatureComponentPublicInstance
支持横竖屏切换、支持背景色、笔触大小、笔触颜色、背景颜色配置
平台兼容性
UniApp X
| Android | iOS | web | 鸿蒙 Next | 小程序 |
|---|---|---|---|---|
| √ | √ | √ | √ | √ |
UniApp Vue Nvue
| Android | iOS | web | 鸿蒙 Next | 小程序 |
|---|---|---|---|---|
| x | x | √ | x | x |
Props
| 属性名 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| text | String | 签名区 | 背景文字 |
| size | Number | 2 | 笔触大小 |
| theme | String | info | 主题 |
| color | String | $ux.Conf.infoColor | 笔触颜色 |
| background | String | $ux.Conf.backgroundColor | 背景颜色 |
| confirm | String | 确定 | 确定文字 |
| confirmColor | String | $ux.Conf.primaryColor | 确定文字颜色 |
| minWidth | Number | 2 | 最小宽度 |
| maxWidth | Number | 6 | 最大宽度 |
| minSpeed | Number | 1.5 | 最小速度 |
| maxHistory | Number | 20 | 最大可撤销记录 |
| fullScreen | Boolean | false | 全屏 |
| format | String | png | 图片格式 |
| showBtns | Boolean | true | 显示操作按钮 |
| disableScroll | Boolean | true | 禁止屏幕滚动 |
| disabled | Boolean | false | 是否禁用 |
| margin | Array | 边距[上右下左][上下左右][上下左右] | |
| mt | Number | 距上单位px | |
| mr | Number | 距右单位px | |
| mb | Number | 距下单位px | |
| ml | Number | 距左单位px | |
| padding | Array | 填充[上右下左][上下左右][上下左右] | |
| pt | Number | 上内边距单位px | |
| pr | Number | 右内边距单位px | |
| pb | Number | 下内边距单位px | |
| pl | Number | 左内边距单位px | |
| xstyle | Array | 自定义样式 |
theme
| 值 | 说明 |
|---|---|
| text | 文字 |
| info | 默认 |
| primary | 主要 |
| success | 成功 |
| warning | 警告 |
| error | 错误 |
fullScreen
| 值 | 说明 |
|---|---|
| true | |
| false |
format
| 值 | 说明 |
|---|---|
| png | |
| jpg |
showBtns
| 值 | 说明 |
|---|---|
| true | |
| false |
disableScroll
| 值 | 说明 |
|---|---|
| true | |
| false |
disabled
| 值 | 说明 |
|---|---|
| true | |
| false |
Events
| 事件名 | 说明 | 参数 |
|---|---|---|
| change | 生成签名时触发 |
示例代码
html
<template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="手写板签名" :bold="true">
<ux-text text="支持横竖屏切换、支持背景色、笔触大小、笔触颜色、背景颜色配置"></ux-text>
</ux-card>
<ux-signature ref="signature" :fullScreen="false" :color="color" :size="5" :mt="30" @change="onChange"></ux-signature>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template><template>
<ux-page :stack="showDoc">
<ux-navbar :title="title" :border="false">
<template v-slot:right>
<!-- #ifndef MP -->
<ux-button theme="text" icon="/static/tip.png" :icon-size="22" @click="onDoc()"></ux-button>
<!-- #endif -->
</template>
</ux-navbar>
<ux-scroll>
<ux-card direction="column" icon="flag-filled" title="手写板签名" :bold="true">
<ux-text text="支持横竖屏切换、支持背景色、笔触大小、笔触颜色、背景颜色配置"></ux-text>
</ux-card>
<ux-signature ref="signature" :fullScreen="false" :color="color" :size="5" :mt="30" @change="onChange"></ux-signature>
<ux-placeholder :height="200">
<ux-row justify="center" align="center" style="height: 100%;">
<ux-text prefix-icon="soapbubble-filled" text="真的没有了~"></ux-text>
</ux-row>
</ux-placeholder>
</ux-scroll>
</ux-page>
</template>ts
<script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const color = ref('red')
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/signature.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function onChange(path: string) {
uni.previewImage({
urls: [path]
})
}
</script><script setup>
import * as plus from '@/uni_modules/ux-plus'
const title = ref('')
const color = ref('red')
const showDoc = ref(false)
function onDoc() {
plus.openWeb({
title: '在线文档',
url: 'https://www.uxframe.cn/component/signature.html',
// blur: 1,
success: () => {
showDoc.value = true
},
complete: () => {
showDoc.value = false
}
})
}
onLoad((e) => {
title.value = e['title'] ?? ''
})
function onChange(path: string) {
uni.previewImage({
urls: [path]
})
}
</script>css
<style lang="scss">
</style><style lang="scss">
</style>