【问题标题】:Enabling performance config setting in Vue 3在 Vue 3 中启用性能配置设置
【发布时间】:2020-10-23 15:53:58
【问题描述】:

尝试在 Vue 3 中启用 performance 设置时,出现以下错误:

TypeError: can't access property "performance", app.config is undefined

我的入口点 (main.js) 如下所示:

import App from './App.vue';
import { createApp } from 'vue';

const app = createApp(App).mount('#app');

if (process.env.NODE_ENV === 'development') {
    app.config.performance = true;
}

【问题讨论】:

    标签: javascript vue.js vuejs3


    【解决方案1】:

    这是因为 mount 没有返回应用实例。

    解决方案:

    const app = createApp(App);
    
    if (process.env.NODE_ENV === 'development') {
        app.config.performance = true;
    }
    
    app.mount('#app');
    

    【讨论】:

      猜你喜欢
      • 2018-09-10
      • 2021-03-28
      • 1970-01-01
      • 2017-09-10
      • 1970-01-01
      • 2021-05-15
      • 2021-11-04
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多