``<template>
<view class="addPop">
<uni-popup ref="popup" type="center">
<view class="popup-help-sell">
<view class="text-c van-hairline-bottom" style="padding:0 30rpx 30rpx;margin-bottom: 24rpx;">{{title}}</view>
<view class="popup-input" style="margin-bottom: 24rpx;">
<input v-model="content" maxlength="10" :placeholder="placeholder" placeholder-style="color:#999" />
<view>{{content ? content.length : 0}}/10</view>
</view>
<view class="van-hairline-top popup-add-nav flex justify-between align-center">
<view class="flex justify-center align-center van-hairline-right" @tap="close">取消</view>
<view class="main flex justify-center align-center" @tap="handleConfirm">确认</view>
</view>
</view>
</uni-popup>
</view>
</template>
<script>
export default {
name:"addPop",
data() {
return {
content: '',
};
},
props: {
title: '',
placeholder: '',
defaultValue: '',
canBlank: {
type: Boolean,
default: true
},
ifBlankMsg: {
type: String,
default: '请输入内容'
}
},
watch: {
defaultValue:{
handler(val) {
this.content = this.defaultValue || ''
},
immediate: true
}
},
mounted() {
this.content = this.defaultValue || ''
},
methods: {
handleConfirm() {
if (!this.canBlank) {
if(this.content === ''){
uni.showToast({
icon:'none',
title: this.ifBlankMsg
})
return
}
}
// console.log(`:::${this.content}:::`)
this.$emit('change', this.content)
this.content = ''
this.close()
},
open() {
this.content = this.defaultValue || ''
console.log(131313131312)
this.$refs.popup.open()
},
close() {
this.content = ''
this.$refs.popup.close()
}
}
}
</script>
``
调用
<add-pop :title="popTitle" :placeholder="popTips" :canBlank="false" @change="handleSaveCate" ref="addPop"></add-pop>
ctx.$refs.addPop.open();
或 const addPop = ref(null);addPop.open();
云逻星空 (作者)
正确,运行环境下均正常,发行之后才会出现这种情况
2022-04-05 12:22