NG4与IONIC3开发坑总结

来源:互联网 发布:linux trace ping 编辑:程序博客网 时间:2024/06/05 23:22

为期一个月的项目也到了收尾的时候,之前一直使用angular1,对于NG4不熟悉,不理解,还有那什么public,export都是些什么鬼。不过在不断摸索的过程中,终于完成了项目。现在总结一些在开发中遇到的一些坑,希望对各位初学NG4的人有所帮助。

Q1:compiler.es5.js:1540 Uncaught Error: Can't resolve all parameters for SearchPage: ([object Object], [object Object], [object Object], ?).

R1:constructor参数问题。去检查当前页面constructor参数是否正确,拼写是否正确。参数是否与引入的import文件对应。

Q2:ionic serve与ionic run browser的区别?

R2:ionic serve将您的应用程序作为一个网站运行(意味着它没有任何Cordova功能)
ionic run browser在Cordova浏览器平台中运行您的应用程序,这将注入cordova.js和任何具有浏览器功能的插件

Q3:then( _ => console.log('Directory exists')).下划线啥意思?

R4:没啥意义,代表一个参数,反正又不会使用,搁这儿吧,站位吧

Q4:7.25error: failed to push some refs to 'git@git.oschina.net:mishutechnology/hulk.git'
hint: Updates were rejected because a pushed branch tip is behind its remote

R4:这是git提交时出现的一个错误,head出现了一个新的分支,直接删除会有问题。https://stackoverflow.com/questions/10298291/cannot-push-to-github-keeps-saying-need-merge;解决方案;

Q5:this.file.checkDir(this.cacheBasePath, 'cachefile').then( _=>console.log("Directory exists")).catch(err=> vm.file.createDir(vm.file.dataDirectory, 'cachefile',false).then(_ =>console.log('Directory exists')) .catch(err => console.log('Directory doesnt exist')) );

R5:看ionic3官方文档会让你更理解这个结构;

Q6: 关于localstorage

Q6:localstorage 的值不能直接push,需要通过JSON.parse()与JSON.stringfy()这两个方法来转换。

Q7:基础数组的方法使用?

R7:提高开发效率,总结经常使用的数组方法:push返回数组长度,改变原数组。concat:返回新数组,不改变原数组;

Q8:关于sass伪类;

R8:sass伪类:a {

  font-weight: bold;
  text-decoration: none;
  &:hover { text-decoration: underline; }
  body.firefox & { font-weight: normal; }
},写法在这里,不用找了;

Q9:after清除浮动;

R9:after清除浮动.clearfix:after{
     content:".";        
     display:block;        
     height:0;        
     clear:both;        
     visibility:hidden;  
::-webkit-input-placeholder{
      color:white !important;
    }      
},position不是浮动,这个不起作用。

Q10:GET参数的传递方式不同

R10:getPruchasing(params){
      let seq=this.api.get('api/web/1.0/favorite',params).share();
      return seq;
    }
    deletePrchasing(id){
      let seq=this.api.delete('api/web/1.0/favorite/'+id).share();
      return seq;
    },这两种方式不一样,跟着后台给的方式传;

Q11:if(res.content!= 【】){哈哈哈哈,有坑,对象指针。

Q12:<ion-content class="addressManage" *ngIf="items">
    <ion-grid>
        <ion-row id="fir">
            <ion-col col-12>北京米树科技有限公司</ion-col>
            <button (click)="presentModal();">编辑</button>
        </ion-row>
        <ion-row class="notFir">
            <ion-col col-4 class="col-4">收货地址</ion-col>
            <ion-col col-8 class="col-8">{{items.id}}</ion-col>

R12:跟ng1不一样的事,ng4的循环有时需要做一个ngif判断是否有值,才给你渲染,跟渲染顺序有关;

Q13:封装函数尽量别传全局变量;

Q14:http的状态码;

R14:400:参数有问题;

原创粉丝点击