import { computed, ref, reactive, toRefs, onMounted } from 'vue'
const updateIsReadAll = ref(null)
const isReadAll = ref(false)
<view class="btn-read-all" @tap="readAll()">全部已读</view>
ref 绑定关联
<MessageList ref="updateIsReadAll" :isReadAll="isReadAll" />
2.const readAll = () => {
uni.showModal({
title: '提示',
content: '是否设置当前标题项为全部已读?',
success: (res) => {
if (res.confirm) {
console.log('用户点击确定按钮');
isReadAll.value = true
updateIsReadAll.value.updateIsReadAll()
} else if (res.cancel) {
console.log('用户点击取消');
isReadAll.value = false
}
}
});
}
3.子组件:
const props = defineProps({
isReadAll: {
// 搜索匹配关键词,用来处理高亮展示
type: Boolean,
default: false,
},
})
4.const updateIsReadAll = () => {
let currentIndex = currentTab.value;
let info = tabs.value[currentTab.value]
console.log('info ===', info);
//调取刷新全部已读的数据接口
readAllApiInfo()
}
defineExpose({
updateIsReadAll
})