qdwang
V2EX  ›  Vue.js

vue 发现了 runtime 错误,都要去组件里,手工定位吗?

  •  
  •   qdwang · Mar 1, 2017 · 5202 views
    This topic created in 3390 days ago, the information mentioned may be changed or developed.

    比如报了一个错

    TypeError: Cannot read property 'clientWidth' of undefined
    

    但是显示在 vue.runtime.esm.js 里

    没法自动定位到错误的地方,应该怎么做才能定位到错误的地方呢?

    5 replies    2017-03-02 09:16:29 +08:00
    s0f
        1
    s0f  
       Mar 1, 2017   ❤️ 1
    clientWidth undefined~页面哪里引用了这个属性很好找吧。
    这个错误一般应该是在渲染时发现没有这个属性引起的,这个阶段的错误貌似定位不了具体位置
    qdwang
        2
    qdwang  
    OP
       Mar 1, 2017
    @s0f 就是说这个阶段的错误,必须只能靠手工来查找了是吗?
    songjiaxin2008
        3
    songjiaxin2008  
       Mar 1, 2017
    所以尽量不要写匿名 component ,具名组件很容易找到在哪里出了问题。
    qdwang
        4
    qdwang  
    OP
       Mar 1, 2017 via iPhone
    @songjiaxin2008 不是匿名的呀
    s0f
        5
    s0f  
       Mar 2, 2017
    @qdwang 是的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3204 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 32ms · UTC 06:02 · PVG 14:02 · LAX 23:02 · JFK 02:02
    ♥ Do have faith in what you're doing.