今天有个需求,pc和mobile都需要加弹出框展示,并且前面加空格,
pc使用 Unicode 的全角空格字符 \u3000
来代替空格,通过多次重复添加多个空格。
this.$alert('\u3000\u3000\u3000近一周内' + '${ydsd}存在订单', '提示', {
confirmButtonText: '确定',
});
this.$alert(`\u3000\u3000在一周内,${wod}有${come}个文件没有回复`);
移动端vant使用 white-space: pre-wrap;
样式属性来保留空格,并使用
代替空格。
Dialog.alert({
title: '标题',
message: '弹窗内容 带有空格',
messageAlign: 'left', // 设置消息内容左对齐
className: 'custom-dialog' // 添加自定义类名
}).then(() => {
// 弹窗关闭后的回调函数
});
然后,在你的 CSS 文件(或 <style>
标签)中添加以下样式:
.custom-dialog .van-dialog__message {
white-space: pre-wrap;
}