js:常用的3种弹出提示框(alert、confirm、prompt)
函数定义function alert(message?: any): voidfunction confirm(message?: string): booleanfunction prompt(message?: string, _default?: string): string使用示例1、提示框 alert// 没有返回值alert('你好');2、确认框 confirm// 返回 fals
·
函数定义
function alert(message?: any): void
function confirm(message?: string): boolean
function prompt(message?: string, _default?: string): string
使用示例
1、提示框 alert
// 没有返回值
alert('你好');
2、确认框 confirm
// 返回 false/true
let res = confirm('确定删除?');
console.log(res);
3、输入框 prompt
// 返回用户输入的值或null, 第二个值为指定的默认值(可选)
var ret = prompt('请输入您的年龄', 23);
console.log(ret);
更多推荐
已为社区贡献34条内容
所有评论(0)