wx.showmodal中出现输入框
时间: 2023-10-24 18:33:10 浏览: 316
在使用wx.showModal弹出对话框时,可以在content中设置一个输入框。具体做法是:
```javascript
wx.showModal({
title: '提示',
content: '请输入内容',
confirmText: '确定',
cancelText: '取消',
showCancel: true,
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
} else if (res.cancel) {
console.log('用户点击取消');
}
},
// 在content中加入一个输入框
// 输入框的值将通过回调函数传递给success
// 参数res.confirm为true表示用户点击了确定按钮,res.cancel为true表示用户点击了取消按钮
// 参数res.inputValue为输入框中的值
content: '<input type="text" placeholder="请输入内容" style="border:1px solid #ccc;padding:5px;width:100%" autofocus/>',
success: function (res) {
if (res.confirm) {
console.log('用户点击确定');
console.log('输入的内容为:', res.inputValue);
} else if (res.cancel) {
console.log('用户点击取消');
}
}
})
```
在上述代码中,在content中加入了一个输入框,输入框的值将通过回调函数传递给success,参数res.inputValue为输入框中的值。
阅读全文
相关推荐
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![7z](https://img-home.csdnimg.cn/images/20241231044736.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![zip](https://img-home.csdnimg.cn/images/20241231045053.png)
![pdf](https://img-home.csdnimg.cn/images/20241231044930.png)
![docx](https://img-home.csdnimg.cn/images/20241231044901.png)
![rar](https://img-home.csdnimg.cn/images/20241231044955.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)
![](https://csdnimg.cn/download_wenku/file_type_ask_c1.png)