refactor: 确立独立子工程架构 (backend, admin, mpuniapp) 并同步更新 AGENTS.md 规范
这个提交包含在:
@@ -0,0 +1,266 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1">
|
||||
<!-- #endif -->
|
||||
<view style="flex-grow: 1;">
|
||||
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
|
||||
<view>
|
||||
<text>padding-bottom: 25px</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-bottom: 25px;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-bottom: 25px;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>padding-bottom: 10%</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-bottom: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-bottom: 10%;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">scroll-view 组件</text>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text class="uni-subtitle-text">padding-bottom: 10% 和 padding-bottom: 30px</text>
|
||||
<view class="demo-box">
|
||||
<scroll-view class="common" style="padding-bottom: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
<scroll-view class="common" style="padding-bottom: 30px;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
|
||||
</view>
|
||||
|
||||
<!-- 普通版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActual}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRef" class="common-view test-view" :style="{ paddingBottom: data.paddingBottom }">
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActualText}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRef" class="common-text test-text" :style="{ paddingBottom: data.paddingBottom }">当前为text组件当前为text组件</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActualImage}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRef" class="common-image test-image" :style="{ paddingBottom: data.paddingBottom }" src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 拍平版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActualFlat}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRefFlat" class="common-view test-view-flatten" :style="{ paddingBottom: data.paddingBottom }" flatten>
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActualTextFlat}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRefFlat" class="common-text test-text-flatten" :style="{ paddingBottom: data.paddingBottom }" flatten>当前为text组件当前为text组件</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingBottom}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingBottomActualImageFlat}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRefFlat" class="common-image test-image-flatten" :style="{ paddingBottom: data.paddingBottom }" flatten src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt uni-common-mb">
|
||||
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
|
||||
<enum-data :items="paddingBottomEnum" title="padding-bottom 枚举值" @change="radioChangePaddingBottom" :compact="true"></enum-data>
|
||||
<input-data :defaultValue="data.paddingBottom" title="padding-bottom 自定义值" type="text" @confirm="inputChangePaddingBottom"></input-data>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ItemType } from '@/components/enum-data/enum-data-types'
|
||||
|
||||
const data = reactive({
|
||||
paddingBottom: '25px',
|
||||
paddingBottomActual: '',
|
||||
paddingBottomActualText: '',
|
||||
paddingBottomActualImage: '',
|
||||
paddingBottomActualFlat: '',
|
||||
paddingBottomActualTextFlat: '',
|
||||
paddingBottomActualImageFlat: ''
|
||||
})
|
||||
const viewRef = ref(null as UniElement | null)
|
||||
const textRef = ref(null as UniTextElement | null)
|
||||
const imageRef = ref(null as UniImageElement | null)
|
||||
const viewRefFlat = ref(null as UniElement | null)
|
||||
const textRefFlat = ref(null as UniTextElement | null)
|
||||
const imageRefFlat = ref(null as UniImageElement | null)
|
||||
|
||||
const paddingBottomEnum: ItemType[] = [
|
||||
{ value: 0, name: '' },
|
||||
{ value: 1, name: '0' },
|
||||
{ value: 2, name: '0px' },
|
||||
{ value: 3, name: '40px' },
|
||||
{ value: 4, name: '0%' },
|
||||
{ value: 5, name: '20%' }
|
||||
]
|
||||
|
||||
const getPropertyValues = () => {
|
||||
data.paddingBottomActual = viewRef.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
data.paddingBottomActualFlat = viewRefFlat.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
data.paddingBottomActualText = textRef.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
data.paddingBottomActualTextFlat = textRefFlat.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
data.paddingBottomActualImage = imageRef.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
data.paddingBottomActualImageFlat = imageRefFlat.value?.style.getPropertyValue('padding-bottom') ?? ''
|
||||
}
|
||||
|
||||
|
||||
const changePaddingBottom = (value: string) => {
|
||||
data.paddingBottom = value
|
||||
viewRef.value?.style.setProperty('padding-bottom', value)
|
||||
viewRefFlat.value?.style.setProperty('padding-bottom', value)
|
||||
textRef.value?.style.setProperty('padding-bottom', value)
|
||||
textRefFlat.value?.style.setProperty('padding-bottom', value)
|
||||
imageRef.value?.style.setProperty('padding-bottom', value)
|
||||
imageRefFlat.value?.style.setProperty('padding-bottom', value)
|
||||
// 使用 nextTick 确保样式已应用后再获取值
|
||||
nextTick(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
}
|
||||
|
||||
const radioChangePaddingBottom = (index: number) => {
|
||||
const selectedItem = paddingBottomEnum.find((item): boolean => item.value === index)
|
||||
if (selectedItem != null) {
|
||||
changePaddingBottom(selectedItem.name)
|
||||
}
|
||||
}
|
||||
|
||||
const inputChangePaddingBottom = (value: string) => {
|
||||
changePaddingBottom(value)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
radioChangePaddingBottom,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.common {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
.demo-box {
|
||||
flex-direction: row;
|
||||
margin-top: 10px;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.inner-content {
|
||||
flex-grow: 1;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
.common-view {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-text {
|
||||
/* 为了加强视觉效果 */
|
||||
min-height: 40px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.test-item {
|
||||
flex: 1;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.test-box {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.native-view-container-large {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #e0e0e0;
|
||||
border: 2px solid #999;
|
||||
margin: 0 10px;
|
||||
flex-direction: column;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.native-view-padding-large {
|
||||
width: 100%;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1">
|
||||
<!-- #endif -->
|
||||
<view style="flex-grow: 1;">
|
||||
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
|
||||
<view>
|
||||
<text>padding-left: 25px</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-left: 25px;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-left: 25px;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>padding-left: 10%</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-left: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-left: 10%;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">scroll-view 组件</text>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text class="uni-subtitle-text">padding-left: 10% 和 padding-left: 30px</text>
|
||||
<view class="demo-box">
|
||||
<scroll-view class="common" style="padding-left: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
<scroll-view class="common" style="padding-left: 30px;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
|
||||
</view>
|
||||
|
||||
<!-- 普通版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActual}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRef" class="common-dynamic test-view" :style="{ paddingLeft: data.paddingLeft }">
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActualText}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRef" class="common-dynamic test-text" :style="{ paddingLeft: data.paddingLeft }">text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActualImage}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRef" class="common-image test-image" :style="{ paddingLeft: data.paddingLeft }" src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 拍平版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActualFlat}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRefFlat" class="common-dynamic test-view-flatten" :style="{ paddingLeft: data.paddingLeft }" flatten>
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActualTextFlat}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRefFlat" class="common-dynamic test-text-flatten" :style="{ paddingLeft: data.paddingLeft }" flatten>text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingLeft}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingLeftActualImageFlat}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRefFlat" class="common-image test-image-flatten" :style="{ paddingLeft: data.paddingLeft }" flatten src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt uni-common-mb">
|
||||
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
|
||||
<enum-data :items="paddingLeftEnum" title="padding-left 枚举值" @change="radioChangePaddingLeft" :compact="true"></enum-data>
|
||||
<input-data :defaultValue="data.paddingLeft" title="padding-left 自定义值" type="text" @confirm="inputChangePaddingLeft"></input-data>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ItemType } from '@/components/enum-data/enum-data-types'
|
||||
|
||||
const data = reactive({
|
||||
paddingLeft: '25px',
|
||||
paddingLeftActual: '',
|
||||
paddingLeftActualText: '',
|
||||
paddingLeftActualImage: '',
|
||||
paddingLeftActualFlat: '',
|
||||
paddingLeftActualTextFlat: '',
|
||||
paddingLeftActualImageFlat: ''
|
||||
})
|
||||
const viewRef = ref(null as UniElement | null)
|
||||
const textRef = ref(null as UniTextElement | null)
|
||||
const imageRef = ref(null as UniImageElement | null)
|
||||
const viewRefFlat = ref(null as UniElement | null)
|
||||
const textRefFlat = ref(null as UniTextElement | null)
|
||||
const imageRefFlat = ref(null as UniImageElement | null)
|
||||
|
||||
const paddingLeftEnum: ItemType[] = [
|
||||
{ value: 0, name: '' },
|
||||
{ value: 1, name: '0' },
|
||||
{ value: 2, name: '0px' },
|
||||
{ value: 3, name: '20px' },
|
||||
{ value: 4, name: '0%' },
|
||||
{ value: 5, name: '10%' }
|
||||
]
|
||||
|
||||
const getPropertyValues = () => {
|
||||
data.paddingLeftActual = viewRef.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
data.paddingLeftActualFlat = viewRefFlat.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
data.paddingLeftActualText = textRef.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
data.paddingLeftActualTextFlat = textRefFlat.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
data.paddingLeftActualImage = imageRef.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
data.paddingLeftActualImageFlat = imageRefFlat.value?.style.getPropertyValue('padding-left') ?? ''
|
||||
}
|
||||
|
||||
|
||||
const changePaddingLeft = (value: string) => {
|
||||
data.paddingLeft = value
|
||||
viewRef.value?.style.setProperty('padding-left', value)
|
||||
viewRefFlat.value?.style.setProperty('padding-left', value)
|
||||
textRef.value?.style.setProperty('padding-left', value)
|
||||
textRefFlat.value?.style.setProperty('padding-left', value)
|
||||
imageRef.value?.style.setProperty('padding-left', value)
|
||||
imageRefFlat.value?.style.setProperty('padding-left', value)
|
||||
// 使用 nextTick 确保样式已应用后再获取值
|
||||
nextTick(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
}
|
||||
|
||||
const radioChangePaddingLeft = (index: number) => {
|
||||
const selectedItem = paddingLeftEnum.find((item): boolean => item.value === index)
|
||||
if (selectedItem != null) {
|
||||
changePaddingLeft(selectedItem.name)
|
||||
}
|
||||
}
|
||||
|
||||
const inputChangePaddingLeft = (value: string) => {
|
||||
changePaddingLeft(value)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
radioChangePaddingLeft,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.common {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
.demo-box {
|
||||
flex-direction: row;
|
||||
margin-top: 10px;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.inner-content {
|
||||
flex-grow: 1;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
.common-dynamic {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.test-item {
|
||||
flex: 1;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.test-box {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.native-view-container-large {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #e0e0e0;
|
||||
border: 2px solid #999;
|
||||
margin: 0 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.native-view-padding-large {
|
||||
height: 100%;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,267 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1">
|
||||
<!-- #endif -->
|
||||
<view style="flex-grow: 1;">
|
||||
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
|
||||
<view>
|
||||
<text>padding-right: 25px</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-right: 25px;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-right: 25px;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>padding-right: 10%</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-right: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-right: 10%;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">scroll-view 组件</text>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text class="uni-subtitle-text">padding-right: 10% 和 padding-right: 30px</text>
|
||||
<view class="demo-box">
|
||||
<scroll-view class="common" style="padding-right: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
<scroll-view class="common" style="padding-right: 30px;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
|
||||
</view>
|
||||
|
||||
<!-- 普通版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActual}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRef" class="common-view test-view" :style="{ paddingRight: data.paddingRight }">
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActualText}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRef" class="common-text test-text" :style="{ paddingRight: data.paddingRight }">当前为text组件</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActualImage}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRef" class="common-image test-image" :style="{ paddingRight: data.paddingRight }" src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 拍平版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActualFlat}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRefFlat" class="common-view test-view-flatten" :style="{ paddingRight: data.paddingRight }" flatten>
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActualTextFlat}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRefFlat" class="common-text test-text-flatten" :style="{ paddingRight: data.paddingRight }" flatten>当前为text组件</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingRight}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingRightActualImageFlat}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRefFlat" class="common-image test-image-flatten" :style="{ paddingRight: data.paddingRight }" flatten src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt uni-common-mb">
|
||||
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
|
||||
<enum-data :items="paddingRightEnum" title="padding-right 枚举值" @change="radioChangePaddingRight" :compact="true"></enum-data>
|
||||
<input-data :defaultValue="data.paddingRight" title="padding-right 自定义值" type="text" @confirm="inputChangePaddingRight"></input-data>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ItemType } from '@/components/enum-data/enum-data-types'
|
||||
|
||||
const data = reactive({
|
||||
paddingRight: '25px',
|
||||
paddingRightActual: '',
|
||||
paddingRightActualText: '',
|
||||
paddingRightActualImage: '',
|
||||
paddingRightActualFlat: '',
|
||||
paddingRightActualTextFlat: '',
|
||||
paddingRightActualImageFlat: ''
|
||||
})
|
||||
const viewRef = ref(null as UniElement | null)
|
||||
const textRef = ref(null as UniTextElement | null)
|
||||
const imageRef = ref(null as UniImageElement | null)
|
||||
const viewRefFlat = ref(null as UniElement | null)
|
||||
const textRefFlat = ref(null as UniTextElement | null)
|
||||
const imageRefFlat = ref(null as UniImageElement | null)
|
||||
|
||||
const paddingRightEnum: ItemType[] = [
|
||||
{ value: 0, name: '' },
|
||||
{ value: 1, name: '0' },
|
||||
{ value: 2, name: '0px' },
|
||||
{ value: 3, name: '20px' },
|
||||
{ value: 4, name: '0%' },
|
||||
{ value: 5, name: '10%' }
|
||||
]
|
||||
|
||||
const getPropertyValues = () => {
|
||||
data.paddingRightActual = viewRef.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
data.paddingRightActualFlat = viewRefFlat.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
data.paddingRightActualText = textRef.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
data.paddingRightActualTextFlat = textRefFlat.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
data.paddingRightActualImage = imageRef.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
data.paddingRightActualImageFlat = imageRefFlat.value?.style.getPropertyValue('padding-right') ?? ''
|
||||
}
|
||||
|
||||
|
||||
const changePaddingRight = (value: string) => {
|
||||
data.paddingRight = value
|
||||
viewRef.value?.style.setProperty('padding-right', value)
|
||||
viewRefFlat.value?.style.setProperty('padding-right', value)
|
||||
textRef.value?.style.setProperty('padding-right', value)
|
||||
textRefFlat.value?.style.setProperty('padding-right', value)
|
||||
imageRef.value?.style.setProperty('padding-right', value)
|
||||
imageRefFlat.value?.style.setProperty('padding-right', value)
|
||||
// 使用 nextTick 确保样式已应用后再获取值
|
||||
nextTick(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
}
|
||||
|
||||
const radioChangePaddingRight = (index: number) => {
|
||||
const selectedItem = paddingRightEnum.find((item): boolean => item.value === index)
|
||||
if (selectedItem != null) {
|
||||
changePaddingRight(selectedItem.name)
|
||||
}
|
||||
}
|
||||
|
||||
const inputChangePaddingRight = (value: string) => {
|
||||
changePaddingRight(value)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
radioChangePaddingRight,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.common {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
.demo-box {
|
||||
flex-direction: row;
|
||||
margin-top: 10px;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.inner-content {
|
||||
flex-grow: 1;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
.common-view {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-text {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
/* 为了加强视觉效果 */
|
||||
max-width: 100px;
|
||||
}
|
||||
|
||||
.common-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.test-item {
|
||||
flex: 1;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.test-box {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.native-view-container-large {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #e0e0e0;
|
||||
border: 2px solid #999;
|
||||
margin: 0 10px;
|
||||
flex-direction: row;
|
||||
justify-content: flex-end;
|
||||
}
|
||||
|
||||
.native-view-padding-large {
|
||||
height: 100%;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,259 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1">
|
||||
<!-- #endif -->
|
||||
<view style="flex-grow: 1;">
|
||||
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
|
||||
<view>
|
||||
<text>padding-top: 25px</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-top: 25px;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-top: 25px;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>padding-top: 10%</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding-top: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding-top: 10%;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">scroll-view 组件</text>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text class="uni-subtitle-text">padding-top: 10% 和 padding-top: 30px</text>
|
||||
<view class="demo-box">
|
||||
<scroll-view class="common" style="padding-top: 10%;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
<scroll-view class="common" style="padding-top: 30px;">
|
||||
<view class="inner-content"></view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
|
||||
</view>
|
||||
|
||||
<!-- 普通版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActual}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRef" class="common-dynamic test-view" :style="{ paddingTop: data.paddingTop }">
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActualText}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRef" class="common-dynamic test-text" :style="{ paddingTop: data.paddingTop }">text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActualImage}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRef" class="common-image test-image" :style="{ paddingTop: data.paddingTop }" src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 拍平版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActualFlat}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRefFlat" class="common-dynamic test-view-flatten" :style="{ paddingTop: data.paddingTop }" flatten>
|
||||
<view style="flex-grow: 1;background-color: cyan;"><text>view</text></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActualTextFlat}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRefFlat" class="common-dynamic test-text-flatten" :style="{ paddingTop: data.paddingTop }" flatten>text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.paddingTop}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingTopActualImageFlat}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRefFlat" class="common-image test-image-flatten" :style="{ paddingTop: data.paddingTop }" flatten src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt uni-common-mb">
|
||||
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
|
||||
<enum-data :items="paddingTopEnum" title="padding-top 枚举值" @change="radioChangePaddingTop" :compact="true"></enum-data>
|
||||
<input-data :defaultValue="data.paddingTop" title="padding-top 自定义值" type="text" @confirm="inputChangePaddingTop"></input-data>
|
||||
</view>
|
||||
|
||||
</view>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ItemType } from '@/components/enum-data/enum-data-types'
|
||||
|
||||
const data = reactive({
|
||||
paddingTop: '25px',
|
||||
paddingTopActual: '',
|
||||
paddingTopActualText: '',
|
||||
paddingTopActualImage: '',
|
||||
paddingTopActualFlat: '',
|
||||
paddingTopActualTextFlat: '',
|
||||
paddingTopActualImageFlat: ''
|
||||
})
|
||||
const viewRef = ref(null as UniElement | null)
|
||||
const textRef = ref(null as UniTextElement | null)
|
||||
const imageRef = ref(null as UniImageElement | null)
|
||||
const viewRefFlat = ref(null as UniElement | null)
|
||||
const textRefFlat = ref(null as UniTextElement | null)
|
||||
const imageRefFlat = ref(null as UniImageElement | null)
|
||||
|
||||
const paddingTopEnum: ItemType[] = [
|
||||
{ value: 0, name: '' },
|
||||
{ value: 1, name: '0' },
|
||||
{ value: 2, name: '0px' },
|
||||
{ value: 3, name: '20px' },
|
||||
{ value: 4, name: '0%' },
|
||||
{ value: 5, name: '10%' }
|
||||
]
|
||||
|
||||
const getPropertyValues = () => {
|
||||
data.paddingTopActual = viewRef.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
data.paddingTopActualFlat = viewRefFlat.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
data.paddingTopActualText = textRef.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
data.paddingTopActualTextFlat = textRefFlat.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
data.paddingTopActualImage = imageRef.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
data.paddingTopActualImageFlat = imageRefFlat.value?.style.getPropertyValue('padding-top') ?? ''
|
||||
}
|
||||
|
||||
|
||||
const changePaddingTop = (value: string) => {
|
||||
data.paddingTop = value
|
||||
viewRef.value?.style.setProperty('padding-top', value)
|
||||
viewRefFlat.value?.style.setProperty('padding-top', value)
|
||||
textRef.value?.style.setProperty('padding-top', value)
|
||||
textRefFlat.value?.style.setProperty('padding-top', value)
|
||||
imageRef.value?.style.setProperty('padding-top', value)
|
||||
imageRefFlat.value?.style.setProperty('padding-top', value)
|
||||
// 使用 nextTick 确保样式已应用后再获取值
|
||||
nextTick(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
}
|
||||
|
||||
const radioChangePaddingTop = (index: number) => {
|
||||
const selectedItem = paddingTopEnum.find((item): boolean => item.value === index)
|
||||
if (selectedItem != null) {
|
||||
changePaddingTop(selectedItem.name)
|
||||
}
|
||||
}
|
||||
|
||||
const inputChangePaddingTop = (value: string) => {
|
||||
changePaddingTop(value)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
radioChangePaddingTop,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.common {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
.demo-box {
|
||||
flex-direction: row;
|
||||
margin-top: 10px;
|
||||
justify-content: space-around;
|
||||
}
|
||||
.inner-content {
|
||||
flex-grow: 1;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
.common-dynamic {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.test-item {
|
||||
flex: 1;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.test-box {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.native-view-container-large {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #e0e0e0;
|
||||
border: 2px solid #999;
|
||||
margin: 0 10px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
.native-view-padding-large {
|
||||
width: 100%;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
</style>
|
||||
@@ -0,0 +1,344 @@
|
||||
<template>
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
<scroll-view style="flex: 1">
|
||||
<!-- #endif -->
|
||||
<view style="flex-grow: 1;">
|
||||
<text class="uni-tips">说明:左边是正常版本,右边是拍平版本</text>
|
||||
<view>
|
||||
<text>padding: 25px</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding: 25px;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding: 25px;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view>
|
||||
<text>padding: 5%</text>
|
||||
<view class="demo-box">
|
||||
<view class="common" style="padding: 5%;">
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
<view class="common" style="padding: 5%;" flatten>
|
||||
<view class="inner-content"></view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>text组件: padding: 25px</text>
|
||||
<view class="demo-box">
|
||||
<text class="text-padding" style="padding: 25px;">文本</text>
|
||||
<text class="text-padding" style="padding: 25px;" flatten>文本</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>text组件: padding: 5%</text>
|
||||
<view class="demo-box">
|
||||
<text class="text-padding" style="padding: 5%;">文本</text>
|
||||
<text class="text-padding" style="padding: 5%;" flatten>文本</text>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>image组件: padding: 25px</text>
|
||||
<view class="demo-box">
|
||||
<image class="image-padding" style="padding: 25px;" src="/static/test-image/logo.png"></image>
|
||||
<image class="image-padding" style="padding: 25px;" src="/static/test-image/logo.png" flatten></image>
|
||||
</view>
|
||||
</view>
|
||||
<view>
|
||||
<text>image组件: padding: 5%</text>
|
||||
<view class="demo-box">
|
||||
<image class="image-padding" style="padding: 5%;" src="/static/test-image/logo.png"></image>
|
||||
<image class="image-padding" style="padding: 5%;" src="/static/test-image/logo.png" flatten></image>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">setProperty 设置与 getPropertyValue 获取</text>
|
||||
</view>
|
||||
|
||||
<!-- 普通版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActual}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRef" class="common-dynamic test-view" :style="{ padding: data.padding }">
|
||||
<view style="flex-grow: 1;background-color: cyan;">
|
||||
<text class="common-text">view</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualText}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRef" class="common-dynamic common-text test-text" :style="{ padding: data.padding }">text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualImage}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRef" class="common-image test-image" :style="{ padding: data.padding }" src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- 拍平版本 -->
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">view 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualFlat}}</text>
|
||||
<view class="test-box">
|
||||
<view ref="viewRefFlat" class="common-dynamic test-view-flatten" :style="{ padding: data.padding }" flatten>
|
||||
<view style="flex-grow: 1;background-color: cyan;">
|
||||
<text class="common-text">view</text>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">text 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualTextFlat}}</text>
|
||||
<view class="test-box">
|
||||
<text ref="textRefFlat" class="common-dynamic common-text test-text-flatten" :style="{ padding: data.padding }" flatten>text</text>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="test-item">
|
||||
<text class="uni-subtitle-text">image 组件拍平</text>
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualImageFlat}}</text>
|
||||
<view class="test-box">
|
||||
<image ref="imageRefFlat" class="common-image test-image-flatten" :style="{ padding: data.padding }" flatten src="/static/test-image/logo.png"></image>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt">
|
||||
<text class="uni-title-text">scroll-view 组件 padding </text>
|
||||
</view>
|
||||
|
||||
<view class="test-container">
|
||||
<view class="test-item">
|
||||
<text class="uni-info">设置值: {{data.padding}}</text>
|
||||
<text class="uni-info">获取值: {{data.paddingActualScrollView}}</text>
|
||||
<view class="test-box" style="height: 150px;">
|
||||
<scroll-view ref="scrollViewRef" class="common-scroll-view" :style="{ padding: data.padding }">
|
||||
<view class="scroll-view-content">
|
||||
<text class="common-text">scroll-view1</text>
|
||||
</view>
|
||||
<view class="scroll-view-content">
|
||||
<text class="common-text">scroll-view2</text>
|
||||
</view>
|
||||
<view class="scroll-view-content">
|
||||
<text class="common-text">scroll-view3</text>
|
||||
</view>
|
||||
</scroll-view>
|
||||
</view>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<view class="uni-common-mt uni-common-mb">
|
||||
<text class="uni-tips">第一个枚举值,'' (空字符串) - 空值情况</text>
|
||||
<enum-data :items="paddingEnum" title="padding 枚举值" @change="radioChangePadding" :compact="true"></enum-data>
|
||||
<input-data :defaultValue="data.padding" title="padding 自定义值" type="text" @confirm="inputChangePadding"></input-data>
|
||||
</view>
|
||||
</view>
|
||||
|
||||
<!-- #ifdef APP && !VUE3-VAPOR -->
|
||||
</scroll-view>
|
||||
<!-- #endif -->
|
||||
</template>
|
||||
|
||||
<script setup lang="uts">
|
||||
import { ItemType } from '@/components/enum-data/enum-data-types'
|
||||
|
||||
const data = reactive({
|
||||
padding: '20px',
|
||||
paddingActual: '',
|
||||
paddingActualText: '',
|
||||
paddingActualImage: '',
|
||||
paddingActualFlat: '',
|
||||
paddingActualTextFlat: '',
|
||||
paddingActualImageFlat: '',
|
||||
paddingActualScrollView: ''
|
||||
})
|
||||
const viewRef = ref(null as UniElement | null)
|
||||
const textRef = ref(null as UniTextElement | null)
|
||||
const imageRef = ref(null as UniImageElement | null)
|
||||
const viewRefFlat = ref(null as UniElement | null)
|
||||
const textRefFlat = ref(null as UniTextElement | null)
|
||||
const imageRefFlat = ref(null as UniImageElement | null)
|
||||
const scrollViewRef = ref(null as UniElement | null)
|
||||
|
||||
const paddingEnum: ItemType[] = [
|
||||
{ value: 0, name: '' },
|
||||
{ value: 1, name: '0' },
|
||||
{ value: 2, name: '0px' },
|
||||
{ value: 3, name: '10px' },
|
||||
{ value: 4, name: '0%' },
|
||||
{ value: 5, name: '5%' }
|
||||
]
|
||||
|
||||
const getPropertyValues = () => {
|
||||
data.paddingActual = viewRef.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualFlat = viewRefFlat.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualText = textRef.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualTextFlat = textRefFlat.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualImage = imageRef.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualImageFlat = imageRefFlat.value?.style.getPropertyValue('padding') ?? ''
|
||||
data.paddingActualScrollView = scrollViewRef.value?.style.getPropertyValue('padding') ?? ''
|
||||
}
|
||||
|
||||
|
||||
const changePadding = (value: string) => {
|
||||
data.padding = value
|
||||
viewRef.value?.style.setProperty('padding', value)
|
||||
viewRefFlat.value?.style.setProperty('padding', value)
|
||||
textRef.value?.style.setProperty('padding', value)
|
||||
textRefFlat.value?.style.setProperty('padding', value)
|
||||
imageRef.value?.style.setProperty('padding', value)
|
||||
imageRefFlat.value?.style.setProperty('padding', value)
|
||||
scrollViewRef.value?.style.setProperty('padding', value)
|
||||
// 使用 nextTick 确保样式已应用后再获取值
|
||||
nextTick(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
}
|
||||
|
||||
const radioChangePadding = (index: number) => {
|
||||
const selectedItem = paddingEnum.find((item): boolean => item.value === index)
|
||||
if (selectedItem != null) {
|
||||
changePadding(selectedItem.name)
|
||||
}
|
||||
}
|
||||
|
||||
const inputChangePadding = (value: string) => {
|
||||
changePadding(value)
|
||||
}
|
||||
|
||||
onReady(() => {
|
||||
getPropertyValues()
|
||||
})
|
||||
|
||||
defineExpose({
|
||||
radioChangePadding,
|
||||
data
|
||||
})
|
||||
</script>
|
||||
|
||||
<style>
|
||||
.common {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.demo-box {
|
||||
flex-direction: row;
|
||||
margin-top: 10px;
|
||||
justify-content: space-around;
|
||||
}
|
||||
|
||||
.inner-content {
|
||||
flex-grow: 1;
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
.common-native {
|
||||
flex:1;
|
||||
height: 100px;
|
||||
background-color: cyan;
|
||||
border:red solid 1px;
|
||||
}
|
||||
|
||||
.common-dynamic {
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-image {
|
||||
width: 80px;
|
||||
height: 80px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.test-container {
|
||||
flex-direction: row;
|
||||
justify-content: space-between;
|
||||
margin-top: 10px;
|
||||
}
|
||||
|
||||
.test-item {
|
||||
flex: 1;
|
||||
margin: 0 5px;
|
||||
}
|
||||
|
||||
.test-box {
|
||||
width: 100%;
|
||||
height: 80px;
|
||||
background-color: lightgray;
|
||||
}
|
||||
|
||||
.text-padding {
|
||||
flex:1;
|
||||
margin:0 10px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
font-size: 16px;
|
||||
color: black;
|
||||
}
|
||||
|
||||
.image-padding {
|
||||
width: 100px;
|
||||
height: 100px;
|
||||
background-color: gray;
|
||||
}
|
||||
|
||||
.common-scroll-view {
|
||||
height: 100px;
|
||||
border:blue solid 1px;
|
||||
}
|
||||
|
||||
.scroll-view-content {
|
||||
width: 100%;
|
||||
height: 100px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
border: cyan solid 2px;
|
||||
}
|
||||
|
||||
.common-text {
|
||||
font-size: 12px;
|
||||
}
|
||||
|
||||
.native-view-container-large {
|
||||
width: 120px;
|
||||
height: 120px;
|
||||
background-color: #e0e0e0;
|
||||
border: 2px solid #999;
|
||||
margin: 0 10px;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
}
|
||||
|
||||
.cyan {
|
||||
background-color: cyan;
|
||||
}
|
||||
|
||||
</style>
|
||||
在新工单中引用
屏蔽一个用户