web前端全系列 教程
1839个小节阅读:2244k
目录
鸿蒙应用开发
C语言快速入门
JAVA全系列 教程
面向对象的程序设计语言
Python全系列 教程
Python3.x版本,未来主流的版本
人工智能 教程
顺势而为,AI创新未来
大厂算法 教程
算法,程序员自我提升必经之路
C++ 教程
一门通用计算机编程语言
微服务 教程
目前业界流行的框架组合
web前端全系列 教程
通向WEB技术世界的钥匙
大数据全系列 教程
站在云端操控万千数据
AIGC全能工具班
A A
White Night
显示模态对话框,其实就是可以进行交互了
xxxxxxxxxx
<button type="primary" bindtap="clickModalHandle">显示对话框</button>
xxxxxxxxxx
Page({
clickModalHandle(){
wx.showModal({
title: '提示',
content: '这是一个模态弹窗',
success(res) {
if (res.confirm) {
console.log('用户点击确定')
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
属性 | 类型 | 默认值 | 必填 | 说明 |
---|---|---|---|---|
title | string | 否 | 提示的标题 | |
content | string | 否 | 提示的内容 | |
showCancel | boolean | true | 否 | 是否显示取消按钮 |
cancelText | string | 取消 | 否 | 取消按钮的文字,最多 4 个字符 |
cancelColor | string | #000000 | 否 | 取消按钮的文字颜色,必须是 16 进制格式的颜色字符串 |
confirmText | string | 确定 | 否 | 确认按钮的文字,最多 4 个字符 |
confirmColor | string | #576B95 | 否 | 确认按钮的文字颜色,必须是 16 进制格式的颜色字符串 |
editable | boolean | false | 否 | 是否显示输入框 |
placeholderText | string | 否 | 显示输入框时的提示文本 |
object.success 回调函数
属性 | 类型 | 说明 |
---|---|---|
content | string | editable 为 true 时,用户输入的文本 |
confirm | boolean | 为 true 时,表示用户点击了确定按钮 |
cancel | boolean | 为 true 时,表示用户点击了取消 |
xxxxxxxxxx
Page({
clickModalHandle(){
wx.showModal({
title: '提示',
// content: '这是一个模态弹窗',
showCancel:true,
cancelText:"残忍拒绝",
cancelColor:"#ff0000",
confirmText:"欣然接受",
confirmColor:"#00ff00",
editable:true,
placeholderText:"请输入信息",
success(res) {
if (res.confirm) {
// res.content获取用户输入信息
console.log('用户点击确定',res.content)
} else if (res.cancel) {
console.log('用户点击取消')
}
}
})
}
})
实时效果反馈
1. 在微信小程序中,下列那个属性可以设置 showModal
显示输入框 :
A showCancel
B placeholderText
C editable
D confirmText
答案
1=>C