美文网首页前端
angularjs中错误总结

angularjs中错误总结

作者: 箱猫日和 | 来源:发表于2015-10-18 23:17 被阅读5951次
    1. cookie
      域名下面 有cookie,document.cookie获取的是cookie的集合
      var cokie = document.cookie.split("=")[1]; //获取cookie*
      http://www.itxueyuan.org/view/6376.html

    2. 在成功获取用户信息之后,调用商品和菜价和信息/
      分页时,再次调用商品和菜价的信息
      疑问:能否只调用一次----将分页更改到成功获取用户信息之后,调用一次。。。。。成功获取用户信息放在最高层(研究run.js)

    3. 重定向问题
      angularjs中的重定向问题
      js中重定向

    4. 考虑500等等错误码页面的显示及提示问题(产品,前端)
      需要考虑清楚页面的各种报错,出错的情况以及交互展示,用户体验的问题

    5. Srv的then先发生还是控制器调用的Srv先发生

    6. 前期不完善

    7. 数据没有加载出来之前,内容不要出来

    8. 有餐厅才有菜单 --- 分开来调用接口了,合在一块

    9. 数据延迟,显示可能有误

    F8A79A05-C7AB-4368-95E6-CE8CA626CF7F.png

    waiting 时间太长---- 查看waiting 的意思,以及TTFB,

    TTFB,是最初的网络请求被发起到从服务器接收到第一个字节这段时间,它包含了TCP连接时间,发送HTTP请求时间和获得响应消息第一个字节的时间。

    1. 单页,一个html页面对应一个controller,如果两个页面共同调用一个控制器,那么会调用两遍

    2. 无法获取到图片时添加用默认“图片无法加载来替代”

    3. 干掉angularjs路由中的# http://blog.fens.me/angularjs-url/

    4. http://www.html-js.com/article/2975 总结chrome中的network面板

    5. http状态码

    6. 每次刷新都记住当页
      sessionStorage http://javascript.ruanyifeng.com/bom/webstorage.html
      sessionStorage数据的存储仅特定于某个会话中,也就是说数据只保持到浏览器关闭,当浏览器关闭后重新打开这个页面时,之前的存储已经被清除。而 localStorage 是一个持久化的存储,它并不局限于会话

    7. window.moveTo()
      window.scrollTo()

    8. change=“pageChanged"
      方法加括号和不加括号调用,带参和不带参数的不同

    9. if(0) —— 0==false

    10. <span ng-bind="(ori_price + add_price) | number: 2"></span> 小数点过滤两位
      或者<span ng-bind="(ori_price + add_price).toFixed(2)"></span>

    11. 常用的正则表达式 非负数(正实数+0) 正则为:^[0-9]+(.[0-9]+)?$ , h5中type=“number”包括了 e , . , -

    12. 9位的非负实数 ^[0-9]+(.[0-9]{1,9})?$**

    13. 图片加载异常或者404 利用onerror()函数 http://justcode.ikeepstudying.com/2015/09/js%E9%92%88%E5%AF%B9%E5%9B%BE%E7%89%87%E5%8A%A0%E8%BD%BD%E5%8F%8A404%E5%A4%84%E7%90%86/

    或者<img ng-src="{{shopGood.image_url || './img/notShow.jpg'}} " alt="餐厅图片" onerror="javascript:this.src='./img/notShow.jpg'”/>

    24 表单当中type=“text”,数字相加时只能放在js当中,不能放在ng-bind中,parseFloat(),不支持函数, 如果利用+将字符串转换为数字,则不管用。。。。<span>{{(+ shopGood.ori_price) + (+shopGood.add_price)}}</span>

    Paste_Image.png

    依赖注入时的语法错误,名称不对

    26.angularjs中的表单type=“number”会自动把字符串转换为数字? 对

    27.finally(function (){
    dialog.hidePreloader();
    });

    Paste_Image.png

    缺少注入依赖

    Failed to load template: template/modal/backdrop.html

    angular-bootstrap中忘记导入ui-bootstrap-tpls.js

    Paste_Image.png

    路由错误导致

    30.gulpfile中无watch监听会有很严重的缓存问题(不能及时更新)

    Paste_Image.png

    Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
    Error: [$injector:modulerr] Failed to instantiate module ui-router due to:
    Error: [$injector:nomod] Module 'ui-router' is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.

    错误:/angular.module('app',
    [
    'ui-router’ ❌ --> ui.router
    ]
    ).config(
    require('./app/config.js')
    )
    /

    Paste_Image.png

    Uncaught Error: [$injector:modulerr] Failed to instantiate module app due to:
    TypeError: Cannot read property 'otherwise' of undefined

    module.exports = [
    '$stateProvider',
    '$urlRouterProvider’, //缺少
    function($stateProvider,$urlRouterProvider){
    $urlRouterProvider.otherwise("/main"); //表示路由引擎匹配不到路径时,就跳该路径
    $stateProvider.state('main',{
    url : '/main',
    abstract : true,
    templateUrl : 'main.html'
    })
    }
    ];

    1. angular-template

    34.一直报错找不到相对页面 404
    gulpfile 里缺少对html视图的自动化,将html页面的模板都压缩在tempaltes.js中,然后相对应的config中的路由根据此去查找
    缺少了 require('../views/templates');

    相关文章

      网友评论

      本文标题:angularjs中错误总结

      本文链接:https://www.haomeiwen.com/subject/aniacttx.html