uniapp 微信小程序 uni.modal弹框+content内容自定义(内容换行)

效果图:

1、template

bash 复制代码
<view  @click="showPriceDialog"></view>

2、data

bash 复制代码
data() {
	return {
		contentText:"",
	}
},

3、methods

bash 复制代码
// 价格公示
showPriceDialog: function() {
	// 吨
	let minPriceTon = 1900
	let maxPriceTon = 3895
	
	// 袋
	let minPriceBag = 890
	let maxPriceBag = 1785
	
	// 车
	let minPriceCar = 56
	let maxPriceCar = 499
	
	this.contentText = "每吨 "+minPriceTon+"至"+maxPriceTon+"元\n每袋"+minPriceBag+"至"+maxPriceBag+"元\n每车"+minPriceCar+"至"+maxPriceCar+"元"
	//换行
	let contentInfo = this.contentText.replace(/<br>/g,"\n")
	                             
	uni.showModal({
		title: "价格公示",
		content: contentInfo,
		confirmText: "确定",
		showCancel: false,
		success: (res) => {
			
		}
	})
},
相关推荐
moshuying30 分钟前
网购能买Token了!
前端
h_654321038 分钟前
echarts实现柱状图加一条横线
前端·echarts
风骏时光牛马1 小时前
生成一个后端标题,只需要一个标题,不需要其他的任何文本。
前端
子非鱼@Itfuture1 小时前
关于前后端联调中登录状态/登录信息失效?
java·前端
郭小李1 小时前
openFeign入门
java·开发语言·前端
馒头不想说话1 小时前
AI当运营,帮你省人力
前端
梦曦i1 小时前
uni-app x下自研架构的工程化突围
前端·架构·uni-app x
速易达网络2 小时前
ECharts 图表制作完全指南:从零到可视化实战
前端·javascript·echarts
IT_陈寒2 小时前
SpringBoot多环境配置把我坑惨了,这个踩坑经验你最好看看
前端·人工智能·后端
徐小夕2 小时前
深度剖析 30k star 的编码 Agent DeepSeek-Reasonix:长会话 Token 成本直降 80%
前端·vue.js·github