提交 ad35ce84 编写于 作者: 雪洛's avatar 雪洛

feat: 调整示例项目适配微信小程序

上级 80d76507
......@@ -1909,7 +1909,7 @@
}
},
// #endif
// #ifdef APP-ANDROID || APP-IOS || WEB
// #ifdef APP-ANDROID || APP-IOS || WEB || MP
{
"path": "pages/template/custom-long-list/custom-long-list",
"style": {
......
......@@ -64,9 +64,7 @@
<text class="uni-subtitle-text">依次为lt gt amp apos nbsp ensp emsp效果</text>
</view>
<view class="text-box">
<!-- #ifndef MP-WEIXIN -->
<text :decode="true">&lt; &gt; &amp; &apos;</text>
<!-- #endif -->
<text :decode="true">&lt; &gt; &amp; &apos;</text>
<text :decode="true">uni-app&nbsp;x,终极跨平台方案</text>
<text :decode="true">uni-app&ensp;x,终极跨平台方案</text>
<text :decode="true">uni-app&emsp;x,终极跨平台方案</text>
......
......@@ -195,14 +195,16 @@
open: false,
pages: [] as Page[],
},
// #endif
// #endif
// #ifdef APP || WEB
{
id: 'schema',
url: 'schema',
name: '打开外部链接',
open: false,
pages: [] as Page[],
},
},
// #endif
// #ifdef WEB
{
id: 'browser-element',
......
<template>
<view id="page" class="page">
<view ref="page" class="page">
<text
style="margin: 10px">半屏弹窗,演示了弹出层内scroll-view滚动到顶时由滚变拖。本效果是通过监听TouchEvent实现,当半屏窗口移动时禁用scroll-view的滚动,避免两者的冲突。</text>
<button class="bottomButton" @click="switchHalfScreen(true)">打开弹窗</button>
......@@ -56,7 +56,7 @@
//this.scrollNode?.setAttribute('scroll-y', 'false');
this.scrollNode?.setAttribute('direction', 'none');
// #endif
// #ifdef WEB
// #ifdef WEB || MP
this.scrollDirection = 'none';
// #endif
this.halfNode?.style?.setProperty('transform', 'translateY(' + offset.toFixed(2) + 'px)');
......@@ -71,7 +71,7 @@
//this.scrollNode?.setAttribute('scroll-y', 'true');
this.scrollNode?.setAttribute('direction', 'vertical');
// #endif
// #ifdef WEB
// #ifdef WEB || MP
this.scrollDirection = 'vertical';
// #endif
this.halfNode?.style?.setProperty('transform', 'translateY(' + offset.toFixed(2) + 'px)');
......@@ -110,7 +110,7 @@
//this.scrollNode?.setAttribute('scroll-y', 'true');
this.scrollNode?.setAttribute('direction', 'vertical');
// #endif
// #ifdef WEB
// #ifdef WEB || MP
this.scrollDirection = 'vertical';
// #endif
this.halfScreenY = 0;
......@@ -150,7 +150,7 @@
//this.scrollNode?.setAttribute('scroll-y', 'true');
this.scrollNode?.setAttribute('direction', 'vertical');
// #endif
// #ifdef WEB
// #ifdef WEB || MP
this.scrollDirection = 'vertical';
// #endif
this.halfScreenY = 0;
......@@ -164,24 +164,31 @@
},
onReady() {
this.halfNode = this.$refs['halfScreen'] as UniElement;//uni.getElementById('halfScreen');
this.scrollNode = this.$refs['halfScroll'] as UniElement;//uni.getElementById('halfScroll');
this.halfHeight = this.halfNode!.getBoundingClientRect().height;
this.totalHeight = uni.getElementById('page')?.getBoundingClientRect()?.height ?? 0;//uni.getWindowInfo().windowHeight
this.halfNode?.style?.setProperty('top', this.totalHeight.toFixed(2)+'px');
this.scrollNode = this.$refs['halfScroll'] as UniElement;//uni.getElementById('halfScroll');
this.halfNode!.getBoundingClientRectAsync().then((rect: DOMRect) => {
this.halfHeight = rect.height
});
(this.$refs['page'] as UniElement).getBoundingClientRectAsync().then((rect: DOMRect) => {
this.totalHeight = rect.height
this.halfNode?.style?.setProperty('top', this.totalHeight.toFixed(2)+'px');
});
},
onResize() {
this.halfHeight = this.halfNode?.getBoundingClientRect()?.height ?? 0;
onResize() {
this.halfNode?.getBoundingClientRectAsync().then((rect: DOMRect) => {
this.halfHeight = rect.height
});
this.totalHeight = uni.getWindowInfo().windowHeight;
this.halfNode?.style?.setProperty('top', this.totalHeight.toFixed(2)+'px');
this.halfNode?.style?.setProperty('visibility', 'hidden');
},
onBackPress(): boolean {
// #ifndef MP
if('visible' == this.halfNode?.style?.getPropertyValue('visibility')){
this.switchHalfScreen(false);
return true;
}
return false;
// #endif
}
}
</script>
......
......@@ -49,7 +49,7 @@
}
},
onLoad() {
// #ifdef APP
// #ifdef APP || MP
this.statusBarHeight = uni.getSystemInfoSync().statusBarHeight;
// #endif
this.nviBarHeight = NAVIBARHEIGHT + this.statusBarHeight;
......
......@@ -87,7 +87,7 @@
onReady() {
// 一启动完成,就播放第一个
this.doPlay(0);
// #ifdef APP
// #ifdef APP || MP
//App端适配不同状态栏高度
let backElement = this.$refs['back'] as UniElement;
backElement.style.setProperty('top', uni.getSystemInfoSync().statusBarHeight+'px');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册