本文章用于记录用uni-app开发项目过程中遇到的问题点。
-
在nvue中flex左右布局高度不能自动撑开的问题
<view style="flex-direction: row;"> <view style="background-color: red;width: 200rpx;overflow-wrap: break-word;"> <text>fadfjafjdandfjandjanjisd</text> </view> <view style="background-color: blue;flex:1;"> <text >React Native 看起来很像 React,只不过其基础组件是原生组件而非 web 组件。要理解 React Native 应用的基本结构,首先需要了解一些基本的 React 的概念,比如 JSX 语法、组件、state状态以及props属性。如果你已经了解了 React,那么还需要掌握一些 React Native 特有的知识,</text> </view> </view>效果如下
中间移动端的布局高度显示不正常, 修改方式如下
<view style="flex-direction: row;align-items: flex-start;"><!-- 这儿添加一个align-items:flex-start;属性即可--> <view style="background-color: red;width: 200rpx;overflow-wrap: break-word;"> <text>fadfjafjdandfjandjanjisd</text> </view> <view style="background-color: blue;flex:1;"> <text >React Native 看起来很像 React,只不过其基础组件是原生组件而非 web 组件。要理解 React Native 应用的基本结构,首先需要了解一些基本的 React 的概念,比如 JSX 语法、组件、state状态以及props属性。如果你已经了解了 React,那么还需要掌握一些 React Native 特有的知识,</text> </view> </view> -
在
pages.json中配置了enablePullDownRefresh和navigationBarTitleText不生效的问题。下面的图是修改之后生效的。之前的配置为,对应的文件名为withdrawal-record。不生效的原因是withdrawal-record.nvue和withdrawal.nvue这个可能是编译的时候有可能存在着某些关系。所以建议一个页面的文件夹下不要有相同文件名开头的文件。e.g.withdrawal-record.nvue和withdrawal.nvue这种的页面文件{ "path": "pages/withdrawal/withdrawal-record", "style": { "navigationBarTitleText":"提现记录", "enablePullDownRefresh":true } } -
在Android10中,运行正式包出现了http网络请求错误。
request fail abort statusCode:1解决方法: 在
uni.request方法中添加sslVerify: false这个参数,关闭ssl校验。或者把你服务器的访问地址改为https即可 -
在nvue 中使用fixed布局之后出现了点击穿透。
解决方法:在使用使用fixed布局的元素上面添加
@touchmove.stop.prevent属性即可。 -
ios添加了新的测试机器之后需要重新下载证书进行打包
-
android的webviewvideo组件播放视频失败,一般就是视频地址存在问题。可以下载到本地,用本地路径播放看看。同时要记得在manifest.json里面添加VideoPlayer视频播放模块 -
webview里面播放video全屏{ onLoad() { const webview = this.$scope.$getAppWebview() setTimeout(() => { const wv = webview.children()[0] wv.setStyle({ videoFullscreen: 'landscape' }) },2000); // 需要延迟执行一下 } } -
webview和APP主进程相互通信<!DOCTYPE html> <html> <head> <meta charset="utf-8" /> <meta name="viewport" content="width=device-width, initial-scale=1"> <title></title> <script src="https://unpkg.com/vconsole@latest/dist/vconsole.min.js"></script> <script> // VConsole will be exported to `window.VConsole` by default. var vConsole = new window.VConsole(); </script> <style> body { background-color: #000; } button { width: 200px; height: 50px; outline: none; background-color: green; font-size: 14px; border-radius: 8px; border: none; color: #fff; } </style> </head> <body> <button onclick="handleClick()" type="button" class="button">点我和宿主APP通信</button> <script> function runMethod(data) { console.log('收到主进程发送的消息', data) } function handleClick() { console.log('发送消息...') uni.postMessage({ data: { action: 'message' } }) } document.addEventListener('UniAppJSBridgeReady', function() { console.log('UniAppJSBridgeReady...') uni.getEnv(res => { console.log(res) }) }) </script> <script type="text/javascript" src="./uni.webview.1.5.5.js"></script> </body> </html><template> <web-view ref="webview" src="/static/local.html" @message="handleMessage"></web-view> </template> <script> export default { data() { return { title: 'Hello' } }, onLoad() { const app = getApp() console.log('fdadfa', app) setTimeout(() => { const webview = this.$scope.$getAppWebview() const wv = webview.children()[0] console.log(wv) wv.evalJS(`runMethod({ a: 1, b:2 })`); } }, methods: { handleMessage(params) { console.log('收到webview发送的消息', params) } } } </script>