我正在建造一个简单的古腾堡街区。
Attributes
attributes: {
sign: {
type: \'string\',
source: \'text\',
default: \'+\'
},
size: {
type: \'string\',
default: 16,
selector: \'.plusblok\',
source: \'attributes\',
attributes: \'style\',
property: \'font-size\'
}
},
edit
var attr = props.attributes;
return [
el(InspectorControls, {key: \'inspector\'},
el(components.PanelBody, {
title: \'Details\',
initialOpen: true
},
el(TextControl, {
type: \'text\',
value: attr.sign,
label: \'Teken\',
onChange: function (newSign) {
props.setAttributes({ sign: newSign})
}
}),
el(
RangeControl, {
label: \'Grootte (in px)\',
value: attr.size,
initialPosition: 16,
min: 8,
max: 48,
onChange: function( newSize ) {
props.setAttributes({ size: newSize })
}
}
)
)
),
el(\'div\', {className: props.className},
el(\'div\', {
className: \'plusblok\',
style: {
fontSize: attr.size + \'px\',
}
},
attr.sign
)
)
]
save
var attr = props.attributes;
return (
el(\'div\', {className: props.className},
el(\'div\', {
className: \'plusblok\',
style: {
fontSize: attr.size + \'px\',
}
},
attr.sign
)
)
)
问题在于“选择”
font-size
并将值读入
attributes
-部分当前代码是以下代码的组合
this issue 和
this page in the handbook, 但它不起作用。我做错了什么?