定义示例
// 文件 '@/lib/fabric/src/zGroup/textarea/textarea-default.js
import { fabric } from '@/lib/fabric'
const defaultOpts = {
scheme: 'default',
name: 'textarea',
autoPosition: true,
top: 0,
left: 0,
width: 500,
height: 200
}
const textarea = function (datas, options) {
const { text } = datas
if (!text || typeof text!=='string' || text.length == 0) return
const opt = { ...defaultOpts ,...options }
const { scheme, name, autoPosition, left, top, width, height } = opt
// some code...
}
export default textarea
使用示例
import { fabric } from '@/lib/fabric'
const textareaObj = fabric.zGroup.textarea(datas, options)
数据参数 datas
//options 默认值
{
text: '文字内容'
}
属性 |
名称 |
默认 |
值 |
text |
文字内容 |
“” |
String |
选项参数 options
//options 默认值
{
scheme: 'default',
autoPosition: true,
top: 0,
left: 0,
width: 500,
height: 200,
fontSize: 20,
overflow: 'hidden', // scale / hidden / visible
textIndent: 2, // 首行缩进
letterSpacing: 2, //px
lineHeight: 1.16, //ratio
padding: 30 //内边距
}
属性 |
名称 |
默认 |
值 |
scheme |
样式方案名 |
default |
|
autoPosition |
自动定位 |
true |
Boolean |
top |
顶距 |
0 |
|
left |
左距 |
0 |
|
width |
宽 |
|
500 |
height |
高 |
200 |
|
overflow |
溢出 |
hidden |
scale / hidden / visible |
textIndent |
首行缩进 |
2 |
|
letterSpacing |
字距 |
2 |
|
lineHeight |
行距 |
1.16 |
|
padding |
内边距 |
30 |
|
fontFamily |
字体 |
"Times New Roman" |
|
fontSize |
字号 |
40 |
|
fontStyle |
字样式 |
normal |
|
fontWeight |
粗体 |
normal |
|
textAlign |
对齐方式 |
left |
|
textBackgroundColor |
背景颜色 |
|
|
fill |
填充颜色 |
|
|
stroke |
描边颜色 |
|
|
strokeWidth |
描边宽度 |
|
- |