1.绑定多个class:
[ngClass]="{'trash':image.toBeDeleted,'untrash':!image.toBeDeleted}"
2.一个事件绑定多个方法:用分号隔开
(click)="myClick1();myClick2()"
3.绑定事件不能动态改变:可以设置if条件选择要触发的函数
test(){
if(this.methods == "myAlert1()"){
this.myAlert1();
}else if(this.methods == "myAlert2()"){
this.myAlert2();
}
}
4.ionic事件与js事件相差个on,例:
jss双击:ondblclick
ionic双击:dblclick
5.id绑定*ngFor的索引index:
id={{i}}
6.设置背景图片:
[ngStyle]="{'background-image': 'url(' + backgroundImage +')'}"
其中
backgroundImage = ‘assets/img/background/background-5.jpg’;
7.this作用域问题,直接用类名指定总不会搞错了吧:
class.prototype.变量
8.show,hide是内置的class样式!!!show,hide是内置的class样式!!!show,hide是内置的class样式!!!
9.将项目部署到网站:
现成的www目录,即可部署
10.npm命令下载插件包时的依赖不匹配报错:
升级所要求的依赖,在package中修改,然后npm install
11.ionic build加–prod报错:
版本或者依赖不匹配,删除node_modules,重新下载
11.卸载插件后再安装该插件时报错:
* What went wrong:
Execution failed for task ':clean'.
> Unable to delete file: E:\ionic3App\myApp\platforms\android\build\outputs\apk\android-debug.apk
不知为它要执行删除apk,然后我的apk又刚好复制在剪贴板,所以删除不了。这时手动删除就好。应该是比较少见的错误。
12.Error: Cannot find module 'C:\Users\c\Desktop\sm-coal-app-master\node_modules@ionic\app-scripts':
@ionic\app-scripts版本过旧或者缺失,在package中修改为较新的版本,然后npm install。还未完,看下一条:
13.这个错误跟上面的升级有关,升级@ionic\app-scripts后报错:webpackJsonp is not defined
当浏览器加载好app.js时就会调用webpackJsonp方法,而当找不到此方法时就会报错。
解决方法:在src/index.html加入以下代码:
注意:
1.加在的前面
2.不要加在www目录下的index.html
14:模板有错,注意查看标签(我记得之前模板有错的话页面会变为一片空白,报错控制台。现在页面也有报错了):
Unexpected closing tag "button". It may happen when the tag has already been closed by another tag
15.命令创建没有module的页面
ionic g page lift –no-module
…..
如有错误请指出,谢谢大家。