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) => {
			
		}
	})
},
相关推荐
z***396244 分钟前
Plugin ‘org.springframework.bootspring-boot-maven-plugin‘ not found(已解决)
java·前端·maven
e***582344 分钟前
Nginx 配置前端后端服务
运维·前端·nginx
小奶包他干奶奶1 小时前
Webpack学习——Plugin(插件)
前端·学习·webpack
张拭心1 小时前
AI 从业者需要铭记的时刻:2023年6月30日
前端·ai编程
duansamve1 小时前
支付宝小程序开发工具中如何模拟给页面传参?
小程序·支付宝小程序
我叫张小白。1 小时前
Vue3 Hooks:逻辑复用的解决方案
前端·javascript·vue.js·前端框架·vue
S***t7141 小时前
前端物联网开发
前端·物联网
我叫张小白。1 小时前
Vue3 Props 的使用:组件间数据传递的桥梁
前端·javascript·vue.js·vue3
r***86981 小时前
Nginx解决前端跨域问题
运维·前端·nginx
广州华水科技1 小时前
单北斗GNSS在桥梁变形监测中的关键应用与技术优势分析
前端