【问题标题】:Vue warn Cannot read property of nullVue警告无法读取null的属性
【发布时间】:2017-02-12 03:13:10
【问题描述】:

我是 vue 新手,我一直在尝试解决控制台中关于无法读取 null 属性的警告。我试图在我的道具中设置一个默认值,但没有运气。我可以在:condition 中获取值,但在控制台中它显示警告 can't read property of null

props: ['user']

标题组件内部:

<header-tooltip :total="total" title="High Paying Cash Surveys" :user="user" :condition="user.hpcs" :currency="currency" placeholder="0"></header-tooltip>

警告:

[Vue warn]: Error when evaluating expression "user.hpcs": TypeError: Cannot read property 'hpcs' of null (found in component: <heading>)

【问题讨论】:

    标签: laravel vue.js


    【解决方案1】:

    终于通过阅读vue.js silent api 文档得到了答案。 如果我们希望我们的应用程序处于生产状态,这些人将清除所有 vue 日志和警告。另一种方法是,如果我们通过npm 安装 vue,那么我们应该在刀片中包含缩小的 vue 脚本。使用 minified 可以防止在你的 vue 中出现警告和日志,这对生产目的很有好处。

    找到你的 vue js 并输入以下代码:

    Vue.config.silent = true
    

    【讨论】:

      猜你喜欢
      • 2018-12-29
      • 1970-01-01
      • 2021-08-22
      • 1970-01-01
      • 2020-12-04
      • 2018-07-07
      • 1970-01-01
      • 2018-01-12
      • 2021-02-17
      相关资源
      最近更新 更多