当前位置:首页 > 编程笔记 > 正文
已解决

uni+vue3+firstUI——组件弹框使用 v-model绑定参数

来自网友在路上 177877提问 提问时间:2023-10-30 20:51:20阅读次数: 77

最佳答案 问答题库778位专家为你答疑解惑

说明

将框架弹框组件 封装成子组件,在页面中引用该子组件,传参并控制弹框显示与隐藏。

子组件

<template><view><wh-modal :show="showPopup" :descr="descr" maskClosable @click="onClick" :buttons="buttons"></wh-modal></view>
</template><script>export default {props: {show: {type: Boolean,default: false}},data() {return {buttons: [{//按钮文本,必选text: '取消',//按钮文本颜色,可选color: '#fff',//按钮背景颜色,可选background: '#C5C5C5',//是否为镂空按钮,即背景色为透明,可选plain: false}, {//按钮文本,必选text: '去完善',//按钮文本颜色,可选color: '#fff',//按钮背景颜色,可选background: '#353834',//是否为镂空按钮,即背景色为透明,可选plain: false}],descr: '暂未完善信息',showPopup: false,}},watch: {show(val) {this.showPopup = val}},methods: {onClick(e) {// 关闭弹框this.showPopup = falsethis.$emit('update:show',this.showPopup) //更新// 去认证if (e.index == 1) {uni.$common.to('/pages/mine/register')return}}}}
</script><style lang="scss" scoped></style>

父页面使用

<perfectPup v-model:show="showPup"></perfectPup>
import perfectPup from '@/components/perfectPup/perfectPup.vue'
const showPup = ref(false)
function toYuYueCar() {if (user.state.level == 'unregister') {showPup.value = truereturn}
}
查看全文

99%的人还看了

猜你感兴趣

版权申明

本文"uni+vue3+firstUI——组件弹框使用 v-model绑定参数":http://eshow365.cn/6-28037-0.html 内容来自互联网,请自行判断内容的正确性。如有侵权请联系我们,立即删除!