[英]How to add custom history in HTML5 to prevent android back button to display just previous view in cordova application?
[英]How to add custom queues with back button
我正在查看 SweetAlert2 的文档示例,它生成一个带有步骤的窗口并包含返回按钮。
我找不到根据需要配置不同队列的方法。 根据文档,可以使用 .queue() 对其进行配置,但它对我不起作用。
有谁知道怎么做?
const steps = ['1', '2', '3'] const swalQueueStep = Swal.mixin({ confirmButtonText: 'Forward', cancelButtonText: 'Back', progressSteps: steps, input: 'text', inputAttributes: { required: true }, reverseButtons: true, validationMessage: 'This field is required' }) async function backAndForth () { const values = [] let currentStep for (currentStep = 0; currentStep < steps.length;) { const result = await swalQueueStep.fire({ title: 'Question ' + steps[currentStep], inputValue: values[currentStep], showCancelButton: currentStep > 0, currentProgressStep: currentStep }) if (result.value) { values[currentStep] = result.value currentStep++ } else if (result.dismiss === 'cancel') { currentStep-- } else { break } } if (currentStep === steps.length) { Swal.fire(JSON.stringify(values)) } } backAndForth()
<script src="https://cdn.jsdelivr.net/npm/sweetalert2@9"></script>
const steps = ['1', '2', '3']
const swalQueueStep = Swal.mixin({
confirmButtonText: 'Forward',
cancelButtonText: 'Back',
progressSteps: steps,
input: 'text',
inputAttributes: {
required: true
},
reverseButtons: true,
validationMessage: 'This field is required'
})
async function backAndForth() {
const values = []
let currentStep
for (currentStep = 0; currentStep < steps.length;) {
if (steps[currentStep] == 1) {
var result = await swalQueueStep.fire({
title: 'Question .' + steps[currentStep],
inputValue: values[currentStep],
showCancelButton: currentStep > 0,
currentProgressStep: currentStep
})
} else if (steps[currentStep] == 2) {
var result = await swalQueueStep.fire({
title: 'Question ..' + steps[currentStep],
inputValue: values[currentStep],
showCancelButton: currentStep > 0,
currentProgressStep: currentStep
})
} else if (steps[currentStep] == 3) {
var result = await swalQueueStep.fire({
title: 'Question ...' + steps[currentStep],
inputValue: values[currentStep],
showCancelButton: currentStep > 0,
currentProgressStep: currentStep
})
} else {
break
}
if (result.value) {
values[currentStep] = result.value
currentStep++
} else if (result.dismiss === 'cancel') {
currentStep--
} else {
break
}
if (currentStep === steps.length) {
Swal.fire(JSON.stringify(values))
}
}
}
backAndForth();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.