优化代码

This commit is contained in:
wuxw 2024-06-25 16:59:03 +08:00
parent 93e768f9d5
commit e784796d4c
2 changed files with 12 additions and 6 deletions

View File

@ -1,11 +1,11 @@
<template name="modal"> <template name="modal">
<view class="modalInputBg" v-show="modalData.showModal" @tap="modalData.showModal = false"> <view class="modalInputBg" v-show="showModal" >
<view class="modalInput"> <view class="modalInput">
<view class="modalDiv" @tap.stop="Bubbling"> <view class="modalDiv" @tap.stop="Bubbling">
<view class="title">{{modalData.title}}</view> <view class="title">{{modalData.title}}</view>
<view class="body"><input type="text" v-model="inputVal" value="" :placeholder="modalData.text"/></view> <view class="body"><input type="text" v-model="inputVal" value="" :placeholder="modalData.text"/></view>
<view class="bottom"> <view class="bottom">
<view class="bottomCancel" @tap.stop="modalData.showModal = false">取消</view> <view class="bottomCancel" @tap.stop="showModal = false">取消</view>
<view class="bottomDefine" @tap.stop="onDefine">确定</view> <view class="bottomDefine" @tap.stop="onDefine">确定</view>
</view> </view>
</view> </view>
@ -22,11 +22,15 @@
}, },
data() { data() {
return { return {
inputVal: '' inputVal: '',
showModal:false,
} }
}, },
methods: { methods: {
openModal:function(){
this.showModal = true;
},
onDefine(){ onDefine(){
if(!this.inputVal){ if(!this.inputVal){
uni.showToast({ uni.showToast({
@ -35,7 +39,7 @@
}) })
return; return;
} }
this.modalData.showModal = false this.showModal = false
this.$emit('dataInput', this.inputVal); this.$emit('dataInput', this.inputVal);
this.inputVal = '' this.inputVal = ''
}, },

View File

@ -65,7 +65,7 @@
<view v-else> <view v-else>
<no-data-page></no-data-page> <no-data-page></no-data-page>
</view> </view>
<myModal :modalData='modal' @dataInput='dataInput'></myModal> <myModal ref="myModalRef" :modalData='modal' @dataInput='dataInput'></myModal>
</view> </view>
</template> </template>
@ -282,7 +282,9 @@
stopRepair(item){ stopRepair(item){
this.actItem = item; this.actItem = item;
this.modal.showModal = true //this.modal.showModal = true
this.$refs.myModalRef.openModal();
}, },
// input // input