NavigateEvent:formData 属性
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
NavigateEvent
接口的 formData
只读属性在导航为 POST
表单提交导航的情况下返回表示提交的数据的 FormData
对象,否则返回 null
。
值
FormData
对象,或 null
。
示例
js
navigation.addEventListener("navigate", (event) => {
// 有些导航,例如跨源导航,我们无法拦截。让浏览器正常处理这些导航。
if (!event.canIntercept) {
return;
}
// 不要拦截片段导航或下载。
if (event.hashChange || event.downloadRequest !== null) {
return;
}
event.intercept({
handler() {
if (event.formData) {
processFormDataAndUpdateUI(event.formData, event.signal);
} else {
doSinglePageAppNav(event.destination, event.signal);
}
},
});
});
规范
Specification |
---|
HTML # dom-navigateevent-formdata-dev |
浏览器兼容性
BCD tables only load in the browser
参见
- 现代客户端路由:导航 API
- 导航 API 说明
- Domenic Denicola 的导航 API 在线演示