提交 53fbcdba 作者: 方治民

fix: fui 组件问题修复和优化

上级 cb2cf54d
...@@ -103,6 +103,21 @@ ...@@ -103,6 +103,21 @@
watch: { watch: {
open(val) { open(val) {
this.isOpen = val this.isOpen = val
},
isOpen(val) {
this.$nextTick(async () => {
let parent = this.$parent;
let parentName = parent.$options.name;
while (parentName !== 'PageBody') {
if (parentName === 'fui-collapse-item') {
await parent.init()
}
parent = parent.$parent;
if (!parent) return false;
parentName = parent.$options.name;
}
})
} }
}, },
updated(e) { updated(e) {
...@@ -135,12 +150,14 @@ ...@@ -135,12 +150,14 @@
}, },
methods: { methods: {
init() { init() {
const promise = []
// #ifndef APP-NVUE // #ifndef APP-NVUE
this.getCollapseHeight() promise.push(this.getCollapseHeight())
// #endif // #endif
// #ifdef APP-NVUE // #ifdef APP-NVUE
this.getNvueHeight() promise.push(this.getNvueHeight())
// #endif // #endif
return Promise.all(promise)
}, },
uninstall() { uninstall() {
if (this.collapse) { if (this.collapse) {
...@@ -164,41 +181,49 @@ ...@@ -164,41 +181,49 @@
} }
}, },
getCollapseHeight(index = 0) { getCollapseHeight(index = 0) {
uni.createSelectorQuery() return new Promise((resolve) => {
// #ifndef MP-ALIPAY uni.createSelectorQuery()
.in(this) // #ifndef MP-ALIPAY
// #endif .in(this)
.select(`#${this.elId}`)
.fields({
size: true
}, data => {
if (index >= 10) return
if (!data) {
index++
this.getCollapseHeight(index)
return
}
// #ifdef APP-NVUE
this.height = data.height + 1
// #endif
// #ifndef APP-NVUE
this.height = data.height
// #endif // #endif
this.isHeight = true .select(`#${this.elId}`)
}) .fields({
.exec() size: true
}, data => {
if (index >= 10) return
if (!data) {
index++
this.getCollapseHeight(index)
return
}
// #ifdef APP-NVUE
this.height = data.height + 1
// #endif
// #ifndef APP-NVUE
this.height = data.height
// #endif
this.isHeight = true
resolve(this.height)
})
.exec()
})
}, },
getNvueHeight() { getNvueHeight() {
const result = dom.getComponentRect(this.$refs['fui_collapse__el'], option => { return new Promise((resolve) => {
if (option && option.result && option.size) { const result = dom.getComponentRect(this.$refs['fui_collapse__el'], option => {
// #ifdef APP-NVUE if (option && option.result && option.size) {
this.height = option.size.height + 1 // #ifdef APP-NVUE
// #endif this.height = option.size.height + 1
// #ifndef APP-NVUE // #endif
this.height = option.size.height // #ifndef APP-NVUE
// #endif this.height = option.size.height
this.isHeight = true // #endif
} this.isHeight = true
resolve(this.height)
}
})
}) })
}, },
getCollapse(name = 'fui-collapse') { getCollapse(name = 'fui-collapse') {
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
<view class="fui-il__checkmark" v-if="model.checked"></view> <view class="fui-il__checkmark" v-if="model.checked"></view>
</view> </view>
<view class="fui-il__img-box" v-if="isSrc"> <view class="fui-il__img-box" v-if="isSrc">
<image v-if="model.src" :src="model.src" class="fui-index__list-img" mode="widthFix"></image> <fLazyload v-if="model.src" :src="model.src" class="fui-index__list-img" width="72" height="72" mode="widthFix"></fLazyload>
</view> </view>
<text class="fui-index__list-main">{{model.text || ''}}</text> <text class="fui-index__list-main">{{model.text || ''}}</text>
</view> </view>
...@@ -18,9 +18,13 @@ ...@@ -18,9 +18,13 @@
</template> </template>
<script> <script>
import fLazyload from '../fui-lazyload/fui-lazyload.vue'
//此组件为索引列表item项,若不满足要求可自行调整样式 //此组件为索引列表item项,若不满足要求可自行调整样式
export default { export default {
name: 'f-index-list-item', name: 'f-index-list-item',
components: {
fLazyload
},
props: { props: {
model: { model: {
type: Object, type: Object,
......
...@@ -282,6 +282,7 @@ ...@@ -282,6 +282,7 @@
} }
this.idtHeight = height; this.idtHeight = height;
this.styles = `height:${height}rpx;`; this.styles = `height:${height}rpx;`;
this.lists = lists; this.lists = lists;
// #ifndef APP-NVUE // #ifndef APP-NVUE
uni.createSelectorQuery() uni.createSelectorQuery()
......
...@@ -30,8 +30,9 @@ ...@@ -30,8 +30,9 @@
let iphonex = false; let iphonex = false;
let models = ['iphonex', 'iphonexr', 'iphonexsmax', 'iphone11', 'iphone11pro', 'iphone11promax', let models = ['iphonex', 'iphonexr', 'iphonexsmax', 'iphone11', 'iphone11pro', 'iphone11promax',
'iphone12', 'iphone12mini', 'iphone12pro', 'iphone12promax', 'iphone13', 'iphone13mini', 'iphone12', 'iphone12mini', 'iphone12pro', 'iphone12promax', 'iphone13', 'iphone13mini',
'iphone13pro', 'iphone13promax', 'iphone14', 'iphone14mini', 'iphone13pro', 'iphone13promax', 'iphone14', 'iphone14mini', 'iphone14plus',
'iphone14pro', 'iphone14promax' 'iphone14pro', 'iphone14promax', 'iphone15', 'iphone15mini', 'iphone15plus',
'iphone15pro', 'iphone15promax'
] ]
const model = res.model.replace(/\s/g, "").toLowerCase() const model = res.model.replace(/\s/g, "").toLowerCase()
const newModel = model.split('<')[0] const newModel = model.split('<')[0]
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论