以下有些内容属于转载,但是来源忘记了,原作者看见还请留言指出!
1、 <ion-searchbar style="padding:10px" placeholder="搜索" (ionInput)="getItems($event)" [(ngModel)]="memInput" (ionClear)="clearInput()"></ion-searchbar>
2、模糊查找 显示或隐藏
for (let index = 0; index < this.mem.memInfo.length; index++) {
if (this.mem.memInfo[index].title.indexOf(inputSer) != -1 ||
this.mem.memInfo[index].content.indexOf(inputSer) != -1) {
this.mem.memInfo[index].isDisplay = true;
this.searchNum--;
} else {
this.mem.memInfo[index].isDisplay = false;
this.searchNum++;
}
}
3、npm报错
fatal: unable to access 'https://github.com/vstirbu/PromisesPlugin.git/': SSL certificate problem: unable to get local issuer certificate
解决:npm config set strict-ssl false
4、com.android.ide.common.process.ProcessException: Failed to execute aapt
可能是maven地址使用google地址的原因
可切换maven地址 以下博客有很多地址可以选择--http://blog.csdn.net/whbing1471/article/details/53983779
----------
更换maven镜像,列出一个常用的
http://maven.aliyun.com/nexus/content/groups/public/
5、div左右滑动
(swipe)="onhold($event)"
// 左右滑动
onhold(event) {
// console.log(event);
if (event.deltaX < 0) {
// this.blankClick();
// console.log("左");
} else if (event.deltaX > 0) {
this.enterPanel()
// console.log("右");
}
}
6、查看端口被占用
netstat -ano //查看所有端口
netstat -ano|findstr "1080" //查看1080端口的pid
tasklist|findstr "656" //通过pid查看端口被占用情况
7、Suggestion: add 'tools:replace="android:icon"' to element ----- 资源文件打包失败
在Manifest文件里添加如下代码
<manifest
xmlns:tools="http://schemas.android.com/tools">
<application
tools:replace="android:icon">
8、
Androidstudio3.0 Gradle报错
将 gradle-wrapper.propertie中
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
改为
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
当然 maven地址要改代理,不然有墙下载不下来
9、npm install---------C:\Program Files\Git\bin\git.EXE ls-remote -h -t https://github.com/vstirbu/PromisesPlugin.git
============> git config --global http.sslverify "false"
============> npm install
第九点转自 https://blog.csdn.net/u014182690/article/details/78598769
10、ionic打包 android lbs文件里so包过多
可以在android build.gradle里面
defaultConfig {
versionCode cdvVersionCode ?: new BigInteger("" + privateHelpers.extractIntFromManifest("versionCode"))
applicationId privateHelpers.extractStringFromManifest("package")
if (cdvMinSdkVersion != null) {
minSdkVersion cdvMinSdkVersion
}
ndk {
abiFilters 'armeabi-v7a'
}
}
11、angular组件不自动刷新的情况
①先导入模块
②刷新数据
this.cd.detectChanges();
该方法会检测所有的数据变化并刷新(不仅仅是刷新这个方法所在的界面)
12、ionic 页面被键盘顶起
在AndroidManifest.xml里的启动页activity标签里面加上
android:windowSoftInputMode="adjustPan"
13、打包安卓报错
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:fontVariationSettings
ERROR: In <declare-styleable> FontFamilyFont, unable to find attribute android:ttcIndex
将v4:+改为v4:23+
14、数组去重
例如:arr=[1,2,1,3,1,5,4,2]
Array.from(new Set(arr))=[1, 2, 3, 5, 4]
判断字符串是否为空或空格
(new RegExp("^[ ]+$")).test(' ')
为空返回true
15、
发布项目到npm,并且绑定到github
github创建项目 例如:cordova-plugin-xxx
克隆到本地,进入根目录
创建package.json ------> 执行 npm init
1、登录npm ------> npm login
-----添加用户 npm adduser
-----查看当前用户 npm whoami
2、发布 ----> npm publish
-----部分异常
------1----tunneling socket could not be established, cause=connect ETIMEDOUT 74.122.238.10:88
-----------去掉代理
------2-----npm ERR! no_perms Private mode enable, only admin can publish this module:
------------使用淘宝镜像导致,需要设置回原来的npm镜像 ------> npm config set registry=http://registry.npmjs.org
淘宝镜像npm config set registry=https://registry.npm.taobao.org
------2-----npm ERR! you do not have permission to publish "your module name". Are you logged in as the correct user?
------------modules被占用,需要修改package.json里面的name,重新npm publish
------3----You cannot publish over the previously published version 0.0.1. : cordova-plugin-xiaomo
------------每次上传需要大于之前的版本号
3、更新版本
npm version 1.0.1
npm publish
16、git
监听文件 git update-index --no-assume-unchanged package.json
忽略文件 git update-index --assume-unchanged package.json
17、js替换文本内所有指定内容
data.replace(new RegExp(obj.oldStr, 'g'), obj.newStr)
18.获取当前包名与activity类名
ActivityManager manager= (ActivityManager) getSystemService(Context.ACTIVITY_SERVICE);
ActivityManager.RunningTaskInfo info=manager.getRunningTasks(1).get(0);
info.topActivity.getPackageName();
info.topActivity.getClassName();
19.全局弹窗 利用WindowManager全局弹出
①dialog
AlertDialog.Builder builder=new AlertDialog.Builder(this);
AlertDialog dialog=builder.setMessage("消息")
.setPositiveButton("确定", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
}
}).create();
dialog.getWindow().setType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
dialog.setCanceledOnTouchOutside(true);
if (!dialog.isShowing()){
dialog.show();
}
②popupwindow
View contentView= LayoutInflater.from(MainActivity.this).inflate(R.layout.popup_layout,null);
PopupWindow popupWindow=new PopupWindow(contentView, ViewGroup.LayoutParams.MATCH_PARENT,ViewGroup.LayoutParams.MATCH_PARENT,true);
popupWindow.setWidth(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setHeight(ViewGroup.LayoutParams.WRAP_CONTENT);
popupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
popupWindow.setOutsideTouchable(true);
popupWindow.setTouchable(true);
popupWindow.setWindowLayoutType(WindowManager.LayoutParams.TYPE_SYSTEM_ALERT);
popupWindow.showAtLocation(contentView, Gravity.BOTTOM,0,0);
20.Suggestion: add 'tools:replace="android:value"' to <meta-data> element at AndroidManifest.xml:23:9-25:38 to override
在build.gradle里面加上下面这段 ionic App也是这样操作
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
21.v4和v7包使用冲突解决办法
在项目的build.gradle里面加上 下面这段代码(强制使用相同支持库版本,版本号可以改成自己所需要的),图下有文字,方便复制
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
22.
events.js:183
throw er; // Unhandled 'error' event
^
Error: read ECONNRESET
at TCP.onread (net.js:622:25)
安装3.3.2版本的ws npm install ws@3.3.2