init
This commit is contained in:
33
xhs-mini-demos/api-case/menu-button/menu-button.css
Normal file
33
xhs-mini-demos/api-case/menu-button/menu-button.css
Normal file
@@ -0,0 +1,33 @@
|
||||
.page-section {
|
||||
margin-top: 100px;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
width: 100%;
|
||||
padding: 0 25px;
|
||||
box-sizing: border-box;
|
||||
}
|
||||
.page-body-title {
|
||||
font-size: 30px;
|
||||
line-height: 100px;
|
||||
}
|
||||
.page-body-text {
|
||||
color: #bbb;
|
||||
font-size: 14px;
|
||||
line-height: 20px;
|
||||
margin: 0 0 50px 0;
|
||||
text-align: center;
|
||||
}
|
||||
.page-body-button {
|
||||
width: 100%;
|
||||
}
|
||||
|
||||
.info {
|
||||
text-align: center;
|
||||
}
|
||||
|
||||
.input {
|
||||
height: 40px;
|
||||
padding: 10px;
|
||||
}
|
||||
26
xhs-mini-demos/api-case/menu-button/menu-button.js
Normal file
26
xhs-mini-demos/api-case/menu-button/menu-button.js
Normal file
@@ -0,0 +1,26 @@
|
||||
const __templateJs = require("./templates.js");
|
||||
const __mergePageOptions = require("../../util/mergePageOptions.js");
|
||||
Page(__mergePageOptions({
|
||||
onShareAppMessage() {
|
||||
return {
|
||||
title: 'menu-button',
|
||||
path: 'api-case/menu-button/menu-button'
|
||||
};
|
||||
},
|
||||
data: {
|
||||
context: ''
|
||||
},
|
||||
getMenuButtonBoundingClientRect() {
|
||||
const res = xhs.getMenuButtonBoundingClientRect();
|
||||
if (res.errMsg) {
|
||||
xhs.showToast({
|
||||
title: `调用失败:${res.errMsg}`,
|
||||
duration: 2000
|
||||
});
|
||||
return;
|
||||
}
|
||||
this.setData({
|
||||
content: JSON.stringify(res)
|
||||
});
|
||||
}
|
||||
}, __templateJs));
|
||||
8
xhs-mini-demos/api-case/menu-button/menu-button.json
Normal file
8
xhs-mini-demos/api-case/menu-button/menu-button.json
Normal file
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"navigationBarTitleText": "菜单按钮",
|
||||
"usingComponents": {
|
||||
"showbox": "../../common/component/showbox/index",
|
||||
"box": "../../common/component/container/index",
|
||||
"api-status": "../../common/component/api-status/index"
|
||||
}
|
||||
}
|
||||
11
xhs-mini-demos/api-case/menu-button/menu-button.xhsml
Normal file
11
xhs-mini-demos/api-case/menu-button/menu-button.xhsml
Normal file
@@ -0,0 +1,11 @@
|
||||
<view class="container">
|
||||
<showbox title="获取菜单按钮布局信息">
|
||||
<box>
|
||||
<view>
|
||||
<view class="_text_wrap _mb8">结果:{{content}}</view>
|
||||
<button class="_ui-button" hover-class="_ui-button-hover" bindtap="getMenuButtonBoundingClientRect">点击获取</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
<include src="templates.xhsml" />
|
||||
45
xhs-mini-demos/api-case/menu-button/templates.js
Normal file
45
xhs-mini-demos/api-case/menu-button/templates.js
Normal file
@@ -0,0 +1,45 @@
|
||||
/** 以下内容为自动生成,请勿手动修改 */
|
||||
|
||||
module.exports = {
|
||||
data: {
|
||||
page_data_0: false,
|
||||
|
||||
page_data_1: false,
|
||||
|
||||
page_data_2: false,
|
||||
|
||||
page_data_3: "",
|
||||
},
|
||||
|
||||
page_fun_0() {
|
||||
this.setData({
|
||||
page_data_0: false,
|
||||
page_data_1: false,
|
||||
page_data_2: false,
|
||||
});
|
||||
|
||||
let res;
|
||||
try {
|
||||
res = xhs.getMenuButtonBoundingClientRect() ?? "无返回值";
|
||||
} catch (err) {
|
||||
console.log("fail", res);
|
||||
this.setData({
|
||||
page_data_1: true,
|
||||
page_data_3: JSON.stringify(res),
|
||||
});
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
console.log("success", res);
|
||||
this.setData({
|
||||
page_data_0: true,
|
||||
page_data_3: JSON.stringify(res),
|
||||
});
|
||||
|
||||
console.log("complete", res);
|
||||
this.setData({
|
||||
page_data_2: true,
|
||||
});
|
||||
},
|
||||
};
|
||||
24
xhs-mini-demos/api-case/menu-button/templates.xhsml
Normal file
24
xhs-mini-demos/api-case/menu-button/templates.xhsml
Normal file
@@ -0,0 +1,24 @@
|
||||
<!-- 以下内容为自动生成,请勿手动修改 -->
|
||||
|
||||
<view class="container">
|
||||
<showbox title="getMenuButtonBoundingClientRect演示">
|
||||
<box>
|
||||
<api-status
|
||||
success="{{page_data_0}}"
|
||||
complete="{{page_data_2}}"
|
||||
fail="{{page_data_1}}"
|
||||
text="{{page_data_3}}"
|
||||
>
|
||||
</api-status>
|
||||
<view class="_ui-space _mt8">
|
||||
<button
|
||||
class="_ui-button"
|
||||
hover-class="_ui-button-hover"
|
||||
bindtap="page_fun_0"
|
||||
>
|
||||
触发
|
||||
</button>
|
||||
</view>
|
||||
</box>
|
||||
</showbox>
|
||||
</view>
|
||||
Reference in New Issue
Block a user