// utils/simpleFloat.js - 先测试最基础的悬浮窗 export function createSimpleFloat() { console.log('开始创建悬浮窗...'); // 获取当前页面 const currentWebview = plus.webview.currentWebview(); if (!currentWebview) { console.error('无法获取当前页面webview'); return null; } console.log('当前webview:', currentWebview); // 创建最简单的悬浮窗 const floatView = new plus.nativeObj.View('testFloat', { top: '200px', left: '20px', width: '60px', height: '60px', backgroundColor: '#FF0000', // 使用明显的红色 borderRadius: '30px', borderColor: '#FFFFFF', borderWidth: '2px' }); // 绘制文字 floatView.drawText('浮', { top: '0px', left: '0px', width: '100%', height: '100%' }, { align: 'center', color: '#FFFFFF', size: '24px' }); // 添加到当前页面 currentWebview.append(floatView); // 显示 floatView.show(); console.log('悬浮窗创建完成,添加到页面'); return floatView; }