【问题标题】:If hot module reload works properly in vue native-script?如果热模块重新加载在 vue native-script 中正常工作?
【发布时间】:2022-10-06 09:08:58
【问题描述】:

我按照指南 https://nativescript-vue.org/en/docs/getting-started/installation 做了所有事情。我安装了一个测试应用程序并尝试更改 Home 组件上的消息,但我看到只有 css 会即时重新加载。没有错误,没有问题或注释,只是我的 android 模拟器仅对 css 更改做出反应,但对 js 更改没有反应。同时,在控制台中的每次代码更改(css或js)之后,我看到JS:[HMR][31d47f755865bfccabe9] 成功 |已成功应用更新。了解了原生脚本 vue 曾经存在的所有 HRM 问题,这些问题仍然存在吗? 我的 package.json:

{
  \"name\": \"example-app\",
  \"main\": \"app/app.ts\",
  \"version\": \"1.0.0\",
  \"private\": true,
  \"dependencies\": {
    \"@nativescript/core\": \"~8.3.0\",
    \"@nativescript/theme\": \"~3.0.2\",
    \"nativescript-vue\": \"~2.9.0\"
  },
  \"devDependencies\": {
    \"@nativescript/android\": \"8.3.1\",
    \"@nativescript/preview-cli\": \"1.0.1\",
    \"@nativescript/types\": \"~8.3.0\",
    \"@nativescript/webpack\": \"~5.0.6\",
    \"@types/node\": \"~17.0.21\",
    \"nativescript-vue-template-compiler\": \"~2.9.0\",
    \"typescript\": \"~4.5.5\",
    \"vue\": \"~2.6.12\"
  }
}

我的 webpack.config.js

const webpack = require(\"@nativescript/webpack\");

module.exports = (env) => {
    webpack.init(env);

    // Learn how to customize:
    // https://docs.nativescript.org/webpack

    return webpack.resolveConfig();
};

我的 tsconfig.json

{
  \"compilerOptions\": {
    \"strict\": true,
    \"target\": \"es2017\",
    \"module\": \"esnext\",
    \"moduleResolution\": \"node\",
    \"lib\": [\"dom\", \"es2017\"],
    \"sourceMap\": true,
    \"noEmitHelpers\": true,
    \"importHelpers\": true,
    \"baseUrl\": \".\",
    \"paths\": {
      \"~/*\": [\"app/*\"],
      \"@/*\": [\"app/*\"]
    },
    \"typeRoots\": [\"types\"],
    \"types\": [\"node\"],
    \"allowSyntheticDefaultImports\": true,
    \"esModuleInterop\": true,
    \"experimentalDecorators\": true,
    \"emitDecoratorMetadata\": true,
    \"skipLibCheck\": true
  },
  \"include\": [\"app\", \"types\"],
  \"exclude\": [\"node_modules\", \"platforms\"],
}

    标签: vue.js nativescript


    【解决方案1】:

    我几年前就停止使用 NativeScript hmr。它总是给我带来问题。我与 NativeScript 核心团队的人建立了联系,他们说他们也这样做。

    我使用--no-hmr 运行我的构建,并且只使用完整的应用程序重新加载。

    【讨论】:

      猜你喜欢
      • 2020-09-17
      • 1970-01-01
      • 2019-02-08
      • 2022-07-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多