8.29
This commit is contained in:
@@ -9,12 +9,34 @@
|
||||
<!-- 弹窗内容 -->
|
||||
<view class="dialog-content">
|
||||
<slot name="content">
|
||||
<text class="default-content">{{ content }}</text>
|
||||
<view class="default-content" >
|
||||
<view v-for="item in formatContent(content)" :key="item">{{item}}</view>
|
||||
</view>
|
||||
</slot>
|
||||
</view>
|
||||
|
||||
<!-- 弹窗底部按钮 -->
|
||||
<view class="dialog-footer">
|
||||
<view class="dialog-footer cancelFooter" v-if="showCancel">
|
||||
<view
|
||||
class="dialog-btn"
|
||||
|
||||
@click="oncancel"
|
||||
>
|
||||
<text class="btn-text">{{cancelText}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="dialog-footer okFooter" v-else-if="showConfirm">
|
||||
<view
|
||||
class="dialog-btn okBtn"
|
||||
|
||||
@click="onconfirm"
|
||||
>
|
||||
<text class="btn-text">{{confirmText}}</text>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<view class="dialog-footer" v-else>
|
||||
<view
|
||||
class="dialog-btn cancel"
|
||||
|
||||
@@ -49,13 +71,35 @@
|
||||
type: String,
|
||||
default: ''
|
||||
},
|
||||
|
||||
cancelText:{
|
||||
type: String,
|
||||
default: '取消'
|
||||
},
|
||||
confirmText:{
|
||||
type: String,
|
||||
default: '确定'
|
||||
},
|
||||
showCancel:{
|
||||
type:Boolean,
|
||||
default:false,
|
||||
},
|
||||
showConfirm:{
|
||||
type:Boolean,
|
||||
default:false,
|
||||
},
|
||||
closeOnOverlay: {
|
||||
type: Boolean,
|
||||
default: true
|
||||
}
|
||||
})
|
||||
|
||||
const formatContent=(val)=>{
|
||||
console.log(val)
|
||||
if(!val) return [];
|
||||
// 将字符串按 \n 切割成数组,并过滤掉空字符串
|
||||
const lines = val.split('<br>').filter(line => line.trim() !== '');
|
||||
console.log('格式化后的内容数组:', lines);
|
||||
return lines;
|
||||
}
|
||||
const emit = defineEmits(['close'])
|
||||
|
||||
|
||||
@@ -110,6 +154,7 @@
|
||||
justify-content: center;
|
||||
|
||||
.default-content {
|
||||
white-space:pre-wrap;
|
||||
font-size: 32rpx;
|
||||
color: #333;
|
||||
line-height: 1.5;
|
||||
@@ -163,4 +208,7 @@
|
||||
}
|
||||
}
|
||||
}
|
||||
.cancelFooter,.okFooter{
|
||||
padding: 0;
|
||||
}
|
||||
</style>
|
||||
|
||||
Reference in New Issue
Block a user