用户:
Yfy卡查看:1 回复:3 评论:1 创建时间:2022-12-10T12:30:14
话不多说,在输入框基础上新增两个属性”前置空点“和”后置空点“贼好用!
JS:
const types = {
isInvisibleWidget: false,
type: "213",
icon: "https://waddle.coco-central.cn/static/img/logo/logo-white.svg",
title: "12345",
version: "1.2.0",
isGlobalWidget: false,
properties: [
{
key: '__width',
label: '宽度',
valueType: 'number',
defaultValue: 280,
blockOptions: {
generateBlock: false,
},
},
{
key: '__height',
label: '高度',
valueType: 'number',
defaultValue: 48,
blockOptions: {
generateBlock: false,
},
},
{
key: '__size',
label: '',
valueType: 'number',
defaultValue: 0,
readonly: true,
blockOptions: {
setter: {
keys: ['__height', '__width'],
},
getter: {
keys: ['__height', '__width'],
},
},
},
],
methods: [],
events: [],
};
class Widget extends VisibleWidget {
constructor(props) {
super(props);
this.__width = props.__width;
this.__height = props.__height;
this.enter_text=props.enter_text;
this.prompt_text=props.prompt_text;
this.font_size=props.font_size;
this.qian=props.qian;
this.hou=props.hou;
this.yj=props.yj;
}
render() {
return(
React.createElement("input", { type: 'text',
value: (this.enter_text),
placeholder: (this.prompt_text),
onChange: this.on_change.bind(this),
style: { borderColor: (this.border_color),
padding: ([[0,' ',String(this.hou) + 'px'].join(''),' ',[0,' ',String(this.qian) + 'px'].join('')].join('')),
borderRadius: "9px",
width: "100%",
height: "100%",
outline: 'none',
},
}, null)
);
}
}
types['properties'].push({
key: 'enter_text',
label: '输入文本',
valueType: 'string',
defaultValue: '',
})
types['properties'].push({
key: 'prompt_text',
label: '提示文本',
valueType: 'string',
defaultValue: '请输入:',
})
types['properties'].push({
key: 'font_size',
label: '字号',
valueType: 'number',
defaultValue: 14,
})
types['properties'].push({
key: 'yj',
label: '圆角',
valueType: 'number',
defaultValue: 9,
})
types['properties'].push({
key: 'qian',
label: '前置空处',
valueType: 'number',
defaultValue: 30,
})
types['properties'].push({
key: 'hou',
label: '后置空处',
valueType: 'number',
defaultValue: 35,
})
types['events'].push({
key: 'on_change',
label: '值被改变',
params: [
{
key: 'value',
label: '值',
valueType: 'string',
},],
})
Widget.prototype.on_change = function (event) {
this.setProps({ 'enter_text': event.target.value });
this.emit("on_change" ,event.target.value);
}
exports.types = types;
exports.widget = Widget;
this.yj;