uni-app uni-popup 弹出层 - DCloud前端团队 动态参数
uni-app uni-popup 弹出层 - DCloud前端团队 动态参数
请问这个组件在dialog模式下如何能够动态定义提示的内容啊,试了很多房方法没有用呀,要么报错,要么不显示
1 回复
更多关于uni-app uni-popup 弹出层 - DCloud前端团队 动态参数的实战教程也可以访问 https://www.itying.com/category-93-b0.html
在uni-popup的dialog模式下动态设置内容,可以通过ref获取组件实例,然后修改其content属性来实现:
// 模板
<uni-popup ref="popup" type="dialog">
<uni-popup-dialog :content="dialogContent"></uni-popup-dialog>
</uni-popup>
// 脚本
export default {
data() {
return {
dialogContent: '初始内容'
}
},
methods: {
showPopup() {
// 动态更新内容
this.dialogContent = '这是动态设置的内容'
// 显示弹窗
this.$refs.popup.open()
}
}
}
或者通过ref直接操作:
this.$refs.popupDialog.content = '动态内容'
this.$refs.popup.open()

