新建一个文件夹Suspension(可以自己定义名字)
在文件夹新建Component。(也可以自己定义名字)
wxml页面
<movable-area class="movable-box" style="height:calc(100vh - {{tabBarH}})px">
<slot/>
<movable-view out-of-bounds="true" class='movable-v' x="{{x}}" y="{{y}}" direction="all">
<image class='mybnt' mode="aspectFit" src='../../img/pd.png'> </image>
</movable-view>
</movable-area>
wxss页面
.movable-box {
width: 100vw;
height: calc(100vh - 0rpx);
/* overflow: hidden; */
}
.movable-v {
position: fixed;
width: 150rpx;
height: 150rpx;
z-index: 100;
}
.mybnt {
width: 150rpx;
height: 150rpx;
}
另外两个页面无变动。
在想要使用悬浮图标的页面的json里添加悬浮图标的链接
{
"usingComponents": {
"Suspension":"../Suspension/Suspension"
},
"navigationBarTitleText": "首页"
}
在想要使用悬浮图标的页面的wxml里使用以下标签包住所有内容
<Suspension></Suspension>