this.$confirm提示语换行
时间: 2024-04-18 22:22:13 浏览: 15
在Vue中,使用this.$createElement方法可以创建一个包含多个子元素的节点,从而实现换行的效果。具体实现方法可以参考以下代码:
```
const h = this.$createElement;
this.$confirm('提示', {
title: '提示',
message: h('div', [
h('p', '新建会导致之前设置失效'),
h('p', '是否继续新建?')
]),
confirmButtonText: '确定',
cancelButtonText: '取消'
}).then(() => {
// 调用新建方法
}).catch(() => {}).finally(() => {});
```
其中,h('p', '新建会导致之前设置失效')和h('p', '是否继续新建?')分别表示创建一个p标签,并在其中添加文本内容。通过将这两个p标签作为子元素添加到一个div标签中,就可以实现换行的效果。
相关问题
this.$confirm换行
在使用this.$confirm进行换行时,可以使用$createElement来创建多个p标签,并将它们包裹在一个div标签中。例如,可以使用以下代码进行换行:
```
const h = this.$createElement;
this.$confirm('提示', {
title: '提示',
message: h('div', [
h('p', '是否将该账号密码重置为初始密码?'),
h('p', '成功后将密码设为默认密码,默认密码为用户账号')
]),
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning',
})
.then(() => {
resetPasswords(params).then((res) => {
if (res.code == 200) {
this.$message.success('重置密码成功');
}
});
})
.catch(() => {
this.$message({
type: 'info',
message: '已取消重置密码',
});
});
```
这样可以在确认框中显示多行文本。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [vue this.$confirm中提示的文字换行](https://blog.csdn.net/weixin_45799001/article/details/125086460)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [confirm提示多行内容时换行问题](https://blog.csdn.net/qq_43432057/article/details/116981331)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [js使用小技巧](https://download.csdn.net/download/qq_17486363/7619983)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v93^chatsearchT3_2"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
this.$confirm提示信息换行
你可以在提示信息中使用 `\n` 来插入换行符。例如:
```
this.$confirm('这是第一行\n这是第二行', '提示', {
confirmButtonText: '确定',
cancelButtonText: '取消',
type: 'warning'
});
```
这样会在提示信息中插入一个换行符,使文本换行显示。