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

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

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