docs: 修复 custom 文档不正确问题

This commit is contained in:
wuduoyi 2022-07-13 18:30:28 +08:00 committed by RUNZE LU
parent 0ab3e3aed4
commit 01e1c1b2d6
3 changed files with 7 additions and 5 deletions

View File

@ -41,7 +41,8 @@ order: 26
const button = document.createElement('button');
button.innerText = '点击修改';
button.onclick = event => {
onChange('new'); // 这个 onChange 方法只有放在表单项中才能调用
// 这个 onChange 方法只有放在表单项中才能调用,第二个参数是表单项名称
onChange('new', 'myName');
event.preventDefault();
};
dom.appendChild(button);
@ -148,7 +149,7 @@ onMount: (dom, data, onChange, props) => {
const button = document.createElement('button');
button.innerText = '点击修改姓名';
button.onclick = event => {
onChange('new name');
onChange('new name', 'name');
props.onAction(
event,
{

View File

@ -19,7 +19,8 @@ title: 自定义组件 - SDK
const button = document.createElement('button');
button.innerText = '点击修改姓名';
button.onclick = event => {
onChange('new name');
// 第二个参数是要修改的表单项名称
onChange('new name', 'username');
event.preventDefault();
};
dom.appendChild(button);
@ -52,7 +53,7 @@ title: 自定义组件 - SDK
"name": "username",
"type": "custom",
"label": "自定义组件",
"onMount": "const button = document.createElement('button'); button.innerText = '点击修改姓名'; button.onclick = event => { onChange('new name'); event.preventDefault(); }; dom.appendChild(button);"
"onMount": "const button = document.createElement('button'); button.innerText = '点击修改姓名'; button.onclick = event => { onChange('new name', 'username'); event.preventDefault(); }; dom.appendChild(button);"
}
]
}

View File

@ -74,7 +74,7 @@ export default {
const button = document.createElement('button');
button.innerText = '点击修改姓名';
button.onclick = event => {
onChange('new name');
onChange('new name', 'name');
event.preventDefault();
};
dom.appendChild(button);