ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] # [How to update Ionic cli and libraries](https://www.cnblogs.com/tomkart/p/6991989.html) 1)`npm list outdated` 2)手动修改你项目的 package.json 文件,找对应的版本号 3)`npm update` 重新安装包就可以了。 ## 更新 cordova ionic ~~~ npm update -g cordova ionic ~~~ 执行完成后可以看到cordova和ionic更新后的版本号: 当然最原始的方式 `npm uninstall` ,然后 `npm clean` ,再 `npm install` 也是可以的。 # TypeError: tsDiagnostic.file.getText is not a function u can run ./node_modules/.bin/ngc check what cause the error 所以敲命令: ~~~ ./node_modules/.bin/ngc ~~~ 此时打印出有ERROR的信息,把这些ERROR处理完了,再执行一次打包命令成功。 # Error: ENOENT: no such file or directory AndroidManifest.xml 问题描述: 在ionic 项目中出现编译android 的时候 出现 `Cordova failed to install plugin Error: ENOENT: no such file or directory AndroidManifest.xml` 无法编译android apk 解决方案: ``` cordova platform remove android cordova platform add android@6.4.0 ``` # ERROR TypeError: Cannot read property 'timeStamp' of null https://github.com/ionic-team/ionic/issues/12309#issuecomment-355118279$1 open file `../project/node_modules/ionic-angular/components/infinite-scroll/infinite-scroll.js` then replace this code ~~~ if (this._lastCheck + 32 > ev.timeStamp) { // no need to check less than every XXms return 2; } this._lastCheck = ev.timeStamp; ~~~ with this ~~~ try { if (this._lastCheck + 32 > ev.timeStamp) { // no need to check less than every XXms return 2; } this._lastCheck = ev.timeStamp; } catch (e) { // ev is undefined return 2; } ~~~ Note: you have to start app again `ionic serve`, ionic-app-script wont build on `node_modules` changes # package.json里面依赖包的版本号符号 版本号 `x.y.z`: 其中z 表示一些小的bugfix, 更改z的号, y表示一些大的版本更改,比如一些API的变化 x表示一些设计的变动及模块的重构之类的,会升级x版本号 在 `package.json` 里面 `dependencies` 依赖包的版本号前面的符号有两种,一种是`~`,一种是`^`。 `~`的意思是匹配**最近的小版本** 比如 `~1.0.2` 将会匹配所有的 1.0.x 版本,但不匹配 1.1.0 `^`的意思是匹配**最近的一个大版本** 比如` ^1.0.2` 将会匹配 所有 1.x.x , 但不包括 2.x.x # 检查cordova 打包运行环境 ~~~ $ cordova requirements ~~~ # 新版IONIC3 WKWebView 出现跨域请求的问题 https://www.jianshu.com/p/7fb8482acc91 官方对新版IONIC3使用WKWebView的解释 在iOS中,现在有两个网页浏览器,UIWebView和WKWebView。之前的IONIC版本使用的都是UIWebView。现在都将使用WKWebView。 我们坚信WKWebview是任何应用程序的最佳选择,因为它比旧版的webview(UIWebView)有许多改进。 ## [cordova-plugin-advanced-http](https://ionicframework.com/docs/native/http) 问题1:[Get request with params not working 1.11.1](https://github.com/silkimen/cordova-plugin-advanced-http/issues/97) 问题1: # [__zone_symbol__currentTask Error](https://stackoverflow.com/questions/45905118/zone-symbol-currenttask-error) **Workaround:** To log your underlying error detail, you might try the following: ~~~ JSON.stringify(err, Object.getOwnPropertyNames(err)) ~~~ Though this would not generally be recommended, you could remove the property inserted by Angular if it really bothers you: ~~~ delete error.__zone_symbol__currentTask ~~~ # ionic2点击事件反应慢 点击元素例如 a标签 button 是可以及时响应的,要想提高其他元素的点击的反应速度,加tappable属性即可 `<div tappable (click)="fast()">反应快点</div>` ## Chrome 调试| safari 跨域 Chrome可以安装[CORS Toggle](https://chrome.google.com/webstore/detail/dboaklophljenpcjkbbibpkbpbobnbld)。Safari本身自带该功能,Develop -> Disable Cross Origin Restrictions ~~Nginx代理~~ # ionic2中引入自定义js文件或者引入第三方js文件 http://www.egtch.com ~~~ /// 异步加载js <script async defer type="text/javascript" src="build/bmap.js"></script> // 代码异步追加 js library (在app.component.ts中异步加载) appendDependencyJavascript() { let jsList = ["build/tripledes.js", "build/mode-ecb.js"]; for(let i = 0; i< jsList.length; i++) { let js = jsList[i]; let s = document.createElement("script"); s.type = "text/javascript"; s.src = js; window.setTimeout(()=>{ document.body.appendChild(s); }, 1000 * (i + 1)); } } ~~~ # ionic img `null` 请求404 # If 'ion-col' is an Angular component , then verify that it is part of this module. 用这个不行:https://www.jianshu.com/p/048f8a6c8952 方法:在需要自定义指令的模块中,导入指令模块: ~~~ import {ComponentsModule} from "../../../components/components.module"; ... imports: [ ComponentsModule, ], ~~~~ # 使用 [ion-slides](https://ionicframework.com/docs/api/components/slides/Slides/) 纵向滚动时,内容不滚动直接滚动跳过了,出现问题! 查看 [ion-slides 源码](https://github.com/ionic-team/ionic/tree/master/core/src/components/slides),继承了著名的 Swiper 。 所以查找swiper相关内容: [swiper 内容超出纵向滚动 解决办法](https://github.com/nolimits4web/Swiper/issues/1467),作者还写了一个 [demo](https://jsfiddle.net/8fgphstx/1/)。 有时间做成 指令最好! # Cordova error: Requirements check failed for JDK 1.8 or greater — am using java 9 [duplicate] Uninstall jdk 9 and then install jdk 8. Maybe cordova is not able to detect jdk9>jdk1.8 # [ionic2 tabs使用 Modal底部tab弹出框](https://blog.csdn.net/u010564430/article/details/53942389) # [Ignoring local @import of "animate.css" as resource is missing.)](https://www.abeautifulsite.net/importing-plain-css-files-with-sassscss#/) 明明有资源在那里。那么为什么编译器报告它缺失? 我可能永远不会理解这个设计决策背后的逻辑,但解决方案就是简单地省略 `.css` 后缀名: ~~~ /* Imports animate.css */ @import 'animate'; ~~~ # Cordova 实现沉浸式(透明)状态栏效果 [cordova-plugin-statusbar](https://github.com/apache/cordova-plugin-statusbar) https://segmentfault.com/a/1190000009078477 http://blog.csdn.net/u010730897/article/details/74450922 http://online.sfsu.edu/chrism/hexval.html # ionic2中使用自定义图标 https://www.cnblogs.com/ImaY/p/6955772.html # [ionic2/ionic3打包成App启动慢,ionic3启动长时间白屏解决方案](http://bbs.phonegap100.com/thread-4122-1-1.html) ionic2在使用ionic build android 或者 ionic build ios打包生成的App,启动非常,非常,非常慢!尤其是Android,简直不能忍! 其实官方给出了很简单的解决方法:使用`--prod --release`参数 上面的方法如果不好使可以试试: ~~~ 1.运行ionic build --prod 2.直接用androidstudio运行 或者 cordova run android ~~~ # [px转REM布局实现过程](https://www.jianshu.com/p/ae6555c417ea) # 动画 https://forum.ionicframework.com/t/solved-fade-page-transition/94573/15 # 白屏 `--prod`参数的作用:解决ionic2生成app后启动的白屏问题。具体原理请查看 [解决ionic2 生成app启动白屏的问题](https://www.jianshu.com/p/9af84a4305c0) # xcode-select: error: tool 'xcodebuild' requires Xcode, but ... 参考:https://stackoverflow.com/questions/17980759/xcode-select-active-developer-directory-error # [Ios-deploy install doesn't work - macOS High Sierra (10.13.5)](https://stackoverflow.com/questions/50952245/ios-deploy-install-doesnt-work-macos-high-sierra-10-13-5) ~~~ sudo rm /System/Library/PrivateFrameworks/MobileDevice.framework/XPCServices ~ ~~~ But you need to turn off the `SIP` to be able to do it. # 参考 [ionic3 命令行报错解决方法大全](https://blog.csdn.net/github_37848145/article/details/78286516)