view 父子元素margin-right失效解决办法

本文介绍了如何在uni-app的开发环境中使用Countdown组件,展示了如何设置目标日期(targetDate)和处理计时结束事件(handleCountdownFinished)。CSS样式还展示了组件在页面布局中的具体位置。

开发环境:uni-app

代码环境:

<view class="rightTime">
	<view class="messageInlineTextRight">
		<Countdown :targetDate="endTimes" @countdownFinished="handleCountdownFinished(index)" />
	</view>
</view>

css:

.rightTime{
	display: flex;
}
.messageInlineTextRight{
	position: absolute;
	right: 10rpx;
	bottom: 4rpx;
}

效果:

<template> <view class="page-container"> <!-- 打开弹框的按钮 --> <!-- 遮罩层 --> <view class="mask" v-if="localShow" @click="hideDialog"></view> <!-- 弹框 --> <view class="dialog" :class="{ 'dialog-show': localShow }"> <view class="dialog-content"> <view class="dialog-header"> <text class="dialog-title">提示</text> <text class="close-icon" @click="hideDialog">×</text> </view> <!-- 内容区 --> <view > <text>申请提前结束考核,您的入职考核结束时间=申请审批通过的时间。考核结束后的已缴费订单将都不再计入考核结果,是否确认提前结束考核?</text> </view> <view class="sec"> <view class="inComeList" v-if="filteredActions"> <inComeItem v-for="(item, index) in filteredActions" :key="item.settleMonth" :lastDom="index == filteredActions.length - 1" :data="item" /> </view> <view class="button-group"> <button class="dialog-button" >取消</button> <button class="dialog-button">确认</button> </view> </view> </view> </view> </view> </template> <script> import inComeItem from "../inComeItem/index.vue"; export default { components: { inComeItem, }, props: { showDialog: { type: Boolean, default: false, }, showModel: { type: Boolean, default: false, }, }, watch: { showModel(newVal) { // 监听父组件数据变化 this.localShow = newVal; }, }, data() { return { localShow: this.showDialog, // 本地副本 // 返回假数据 filteredActions: [] }; }, created() { console.log("============onload===========", this.showDialog) }, onload() { console.log("============onload===========", this.showDialog) this.getConfirmApply(); }, methods: { async getConfirmApply(){ const { data } = await uni.$u.http.get("/app/staffAssess/getConfirmApply"); console.log("APP-查询提前结束审批信息",data) }, // 隐藏弹框 hideDialog() { this.localShow = false; this.$emit("update:show-model", false); // 通知父组件更新 }, }, }; </script> <style lang="scss" scoped> .page-container { padding: 20rpx; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif; font-weight: 400; font-style: normal; color: #0d0d0d; background: #f3f5f8; } .mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 998; } .dialog { position: fixed; bottom: -100%; left: 0; width: 100%; height: calc(100% * 2 / 3); transition: bottom 0.3s ease; z-index: 999; display: flex; justify-content: center; align-items: flex-end; // bottom: 0; } .dialog-show { bottom: 0; } .dialog-content { background-color: #fff; width: 100%; height: 100%; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; padding: 30rpx; box-sizing: border-box; } .dialog-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 20rpx; border-bottom: 1rpx solid #ccc; } .dialog-title { font-size: 32rpx; font-weight: normal; text-align: center; flex: 1; } .close-icon { font-size: 36rpx; cursor: pointer; } .radio-group { margin-top: 60rpx; } .radio-item { display: flex; align-items: center; margin-bottom: 10rpx; font-size: 28rpx; } .radio-item radio { transform: scale(0.6); } .audit-status { display: flex; justify-content: space-between; align-items: center; margin-top: 25rpx; padding: 15rpx; padding-top: 30rpx; background-color: rgba(245, 246, 249, 1); border-radius: 15rpx; } .status-label { font-size: 28rpx; } .status-value { display: flex; font-size: 28rpx; } .audit-text { color: #d01212; } .audit-date { color: #666; margin-top: 10rpx; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif; font-weight: 400; font-style: normal; color: #0d0d0d; } .dialog-footer { padding-top: 20rpx; text-align: center; margin-top: 25rpx !important; } /deep/.next-button { width: 80%; padding: 10rpx; background-color: rgba(12, 195, 199, 1) !important; border: none !important; color: #fff !important; border-radius: 15rpx; font-size: 30rpx; } .titleName { margin-top: 40rpx; } .radioName { margin-top: 40rpx; } /* 添加按钮组样式 */ .button-group { display: flex; /* 使用 Flex 布局 */ justify-content: space-between; /* 按钮之间平均分配空间 */ margin-top: 40rpx; /* 顶部间距 */ gap: 20rpx; /* 按钮之间的间隙 */ } /* 按钮样式 */ .dialog-button { flex: 1; /* 每个按钮平分可用空间 */ height: 80rpx; line-height: 80rpx; background-color: rgba(12, 195, 199, 1); color: white; border-radius: 15rpx; font-size: 30rpx; border: none; } </style> <template> <view class="page-container"> <!-- 打开弹框的按钮 --> <!-- 遮罩层 --> <view class="mask" v-if="localShow" @click="hideDialog"></view> <!-- 弹框 --> <view class="dialog" :class="{ 'dialog-show': localShow }"> <view class="dialog-content"> <view class="dialog-header"> <text class="dialog-title">提示</text> <text class="close-icon" @click="hideDialog">×</text> </view> <!-- 内容区 --> <view > <text>申请提前结束考核,您的入职考核结束时间=申请审批通过的时间。考核结束后的已缴费订单将都不再计入考核结果,是否确认提前结束考核?</text> </view> <view class="sec"> <view class="inComeList" v-if="filteredActions"> <inComeItem v-for="(item, index) in filteredActions" :key="item.settleMonth" :lastDom="index == filteredActions.length - 1" :data="item" /> </view> <view class="button-group"> <button class="dialog-button" >取消</button> <button class="dialog-button">确认</button> </view> </view> </view> </view> </view> </template> <script> import inComeItem from "../inComeItem/index.vue"; export default { components: { inComeItem, }, props: { showDialog: { type: Boolean, default: false, }, showModel: { type: Boolean, default: false, }, }, watch: { showModel(newVal) { // 监听父组件数据变化 this.localShow = newVal; }, }, data() { return { localShow: this.showDialog, // 本地副本 // 返回假数据 filteredActions: [] }; }, created() { console.log("============onload===========", this.showDialog) }, onload() { console.log("============onload===========", this.showDialog) this.getConfirmApply(); }, methods: { async getConfirmApply(){ const { data } = await uni.$u.http.get("/app/staffAssess/getConfirmApply"); console.log("APP-查询提前结束审批信息",data) }, // 隐藏弹框 hideDialog() { this.localShow = false; this.$emit("update:show-model", false); // 通知父组件更新 }, }, }; </script> <style lang="scss" scoped> .page-container { padding: 20rpx; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif; font-weight: 400; font-style: normal; color: #0d0d0d; background: #f3f5f8; } .mask { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(0, 0, 0, 0.5); z-index: 998; } .dialog { position: fixed; bottom: -100%; left: 0; width: 100%; height: calc(100% * 2 / 3); transition: bottom 0.3s ease; z-index: 999; display: flex; justify-content: center; align-items: flex-end; // bottom: 0; } .dialog-show { bottom: 0; } .dialog-content { background-color: #fff; width: 100%; height: 100%; border-top-left-radius: 10rpx; border-top-right-radius: 10rpx; padding: 30rpx; box-sizing: border-box; } .dialog-header { display: flex; justify-content: space-between; align-items: center; padding-bottom: 20rpx; border-bottom: 1rpx solid #ccc; } .dialog-title { font-size: 32rpx; font-weight: normal; text-align: center; flex: 1; } .close-icon { font-size: 36rpx; cursor: pointer; } .radio-group { margin-top: 60rpx; } .radio-item { display: flex; align-items: center; margin-bottom: 10rpx; font-size: 28rpx; } .radio-item radio { transform: scale(0.6); } .audit-status { display: flex; justify-content: space-between; align-items: center; margin-top: 25rpx; padding: 15rpx; padding-top: 30rpx; background-color: rgba(245, 246, 249, 1); border-radius: 15rpx; } .status-label { font-size: 28rpx; } .status-value { display: flex; font-size: 28rpx; } .audit-text { color: #d01212; } .audit-date { color: #666; margin-top: 10rpx; font-family: "PingFangSC-Regular", "PingFang SC", sans-serif; font-weight: 400; font-style: normal; color: #0d0d0d; } .dialog-footer { padding-top: 20rpx; text-align: center; margin-top: 25rpx !important; } /deep/.next-button { width: 80%; padding: 10rpx; background-color: rgba(12, 195, 199, 1) !important; border: none !important; color: #fff !important; border-radius: 15rpx; font-size: 30rpx; } .titleName { margin-top: 40rpx; } .radioName { margin-top: 40rpx; } /* 添加按钮组样式 */ .button-group { display: flex; /* 使用 Flex 布局 */ justify-content: space-between; /* 按钮之间平均分配空间 */ margin-top: 40rpx; /* 顶部间距 */ gap: 20rpx; /* 按钮之间的间隙 */ } /* 按钮样式 */ .dialog-button { flex: 1; /* 每个按钮平分可用空间 */ height: 80rpx; line-height: 80rpx; background-color: rgba(12, 195, 199, 1); color: white; border-radius: 15rpx; font-size: 30rpx; border: none; } </style> onload为啥不执行
07-15
<template> <div class="content-box"> <!-- 左侧---> <div class="card filter left-list"> <el-button type="primary" class="add-btn" @click="openDrawerType('新增数据字典',[])">新增字典</el-button> <el-input v-model="filterText" class="filterTextInput" placeholder="请输入" clearable /> <div class="list-box"> <template v-if="treeData.length"> <div :class="['item', { active: activeTypeItem.id === item.id }]" v-for="item in filteredTreeData" :key="item.id" @click="handleItemClick(item)"> <div>{{ item.name }}</div> <div class="right-opearte"> <span @click.stop="openDrawerType('编辑数据字典',item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-editrype' ) "><i class="el-icon-edit"></i>编辑</span> <span @click.stop="handleDelType(item)" v-if="hasBtnPermission( 'system:dataDictionary:btn-deleteType' ) "><i class="el-icon-delete"></i>删除</span> </div> </div> </template> </div> </div> <!-- 右侧-数据列 --> <div class="descriptions-box"> <div class="box-tip card"> <el-button type="primary" class="add-btn" @click="openDrawer('新增字段值', [])">新增字段</el-button> </div> <ProTable ref="proTable" :columns="columns" :request-api="getTableList" :init-param="initParam" :data-callback="dataCallback"> <template #operation="scope"> <el-button type="primary" link @click="openDrawer('编辑字段值', scope.row)">编辑</el-button> <el-button v-if="scope.row.status == 'enabled'" type="primary" style="color:#FF0000" link @click="changeStatus(scope.row)">禁用</el-button> <el-button v-if="scope.row.status == 'disabled'" type="primary" style="color:#49C625" link @click="changeStatus(scope.row)">启用</el-button> <el-button type="primary" link @click="deleteAccount(scope.row)">删除</el-button> </template> </ProTable> </div> <!-- 新增字典类型 --> <addType ref="dialogAddType"/> <!-- 新增编辑字段 --> <addDataDictionary ref="dialogAddDataDictionary"/> </div> </template> <script setup lang="ts" name="dataDictionary"> import { ref, watch, reactive, inject, onMounted, } from "vue"; import { ElTree, FormInstance, FormRules, ElMessage, } from "element-plus"; import { ProTableInstance, ColumnProps } from "@/components/ProTable/interface"; import { Supplier } from "@/api/interface"; import ProTable from "@/components/ProTable/index.vue"; import addDataDictionary from "@/views/system/dataDictionary/addDataDictionary.vue"; import addType from "@/views/system/dataDictionary/addType.vue"; import { setValueList, addDictionaryType, addDictionaryValue } from '@/api/modules/public'; import { da } from "element-plus/es/locale"; const hasBtnPermission: any = inject('hasBtnPermission'); const treeData = ref<any[]>([]); const activeTypeItem = ref<Record<string, any>>({}); const filteredTreeData = ref<any[]>([]); const filterText = ref(""); const defaultProps = { children: "children", label: "label" }; watch( () => filterText.value, (val) => { if (!val) { filteredTreeData.value = treeData.value; } else { const keyword = val.toLowerCase(); filteredTreeData.value = treeData.value.filter(item => item.name?.toLowerCase().includes(keyword) ); } }, { immediate: true } ); // 左侧树 const getTableList = async (params: any) => { const { data } = await setValueList(params); treeData.value = data || []; filteredTreeData.value = data || [] return { list: data || [] }; } const dataCallback = (data: any) => { return data; } const handleItemClick = (data: any) => { activeTypeItem.value = data console.log('data',data) // const response = await assetClassificationInfo({ id: data.id }) } const handleEditType = () => { } const handleDelType = () => { } // 初始化参数 const pageData = reactive({}) // ProTable 实例 const initParam = reactive({}); // 表格配置项 const proTable = ref<ProTableInstance>(); const columns = reactive<ColumnProps<Supplier.pageList>[]>([ // { prop: "realname", label: "姓名", search: { el: "input" } }, ]) // 搜索过滤 const filterNode = (value: string, node: any) => { if (!value) return true; return node.data.label.includes(value); }; // 新增字典类型 const dialogAddType = ref<InstanceType<typeof addType> | null>(null); const openDrawerType = (title: string,row:any) => { const params = { title:title, api: title === "新增数据字典" ? addDictionaryType : addDictionaryType, row:row, getTableListData:getTableList } dialogAddType.value?.acceptParams(params); } // 新增 const dialogAddDataDictionary = ref<InstanceType<typeof addDataDictionary> | null>(null); const openDrawer = (title: string, row: any) => { const params = { title:title, row:row, isView:false, api: title === "新增数据字典" ? addDictionaryType : addDictionaryValue, // getTableListData:getTableList } dialogAddDataDictionary.value?.acceptParams(params); } // 修改状态 const changeStatus = async (row: Supplier.pageList) => { } // 删除 const deleteAccount = async (row: Supplier.pageList) => { } </script> <style scoped lang="scss"> @use "@/styles/treeIndex.scss"; .left-list{ .list-box { height: calc(100% - 95px); overflow: auto; margin-top: 10px; } .item { cursor: pointer; display: flex; justify-content: space-between; padding: 5px 10px; border-radius: 4px; font-size: 14px; color: #606266; &.active { background: #e6f5f3 !important; } &:hover { background: rgb(245, 247, 250); } span { cursor: pointer; margin-left: 10px; i { margin-right: 3px; } &:first-of-type { color: #009688; } &:last-of-type { color: #f56c6c; } } } } </style> <template> <el-drawer v-model="drawerVisible" :destroy-on-close="true" size="550px" :title="drawerProps.title" :close-on-click-modal="false"> <el-form ref="ruleFormRef" label-width="52px" :rules="rules" :model="typeItem"> <el-form-item label="编码" prop="code"> <el-input v-model="typeItem.code" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="名称" prop="name"> <el-input v-model="typeItem.name" placeholder="请填写" class="input-width" maxlength="50" clearable /> </el-form-item> <el-form-item label="备注"> <el-input v-model="typeItem.remark" :rows="6" type="textarea" placeholder="请填写备注" maxlength="5000" show-word-limit clearable></el-input> </el-form-item> </el-form> <template #footer> <el-button @click="drawerVisible = false">取消</el-button> <el-button v-show="!drawerProps.isView" type="primary" @click="handleSubmit">确定</el-button> </template> </el-drawer> </template> <script setup lang="ts" name="addType"> import { ref, reactive } from "vue"; import { AssetClassification } from "@/api/interface"; import { ElMessage, FormInstance } from "element-plus"; const rules = reactive({ code: [{ required: true, message: "请填写字典编码", trigger: "blur" }], name: [{ required: true, message: "请填写字典名称", trigger: "blur" }], }) interface typeItem { code:'', name:'', id:'', remark:'', } interface DrawerProps { title: string, api?: (params: any) => Promise<any>; getTableListData?: () => void; row: Partial<AssetClassification.pageList>; } const formData = ref<Partial<AssetClassification.pageList>>({}); const drawerVisible = ref(false); const drawerProps = ref<DrawerProps>({ title: "", row:{} }) // 接收父组件传过来的参数 const acceptParams = (params: DrawerProps) => { console.log('params',params) typeItem.value = JSON.parse(JSON.stringify(params.row)); drawerProps.value = params; drawerVisible.value = true; } // 操作 const ruleFormRef = ref<FormInstance>(); const handleSubmit = () => { ruleFormRef.value!.validate(async valid => { if (!valid) return; try { await drawerProps.value.api!(drawerProps.value.row); ElMessage.success({ message: `操作成功!` }); drawerProps.value.getTableListData!(); drawerVisible.value = false; } catch (error) { console.log(error); } }) } defineExpose({ acceptParams }); </script> 优化
07-30
评论 1
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值