gpt4 book ai didi

typescript - Nativescript-vue + Typescript - HMR 不适用于 Vue 类组件

转载 作者:行者123 更新时间:2023-12-04 15:31:13 25 4
gpt4 key购买 nike

环境

  • 命令行界面:6.5.0
  • 跨平台模块:6.5.1
  • Android 运行时:6.5.0
  • iOS 运行时:6.5.0

描述错误

用vue类组件样式+typescript保存任何文件时,它根本不更新。给我以下错误:

File change detected. Starting incremental webpack compilation...
Successfully transferred bundle.609c813aedb0d81fb57e.hot-update.js on device emulator-5554.
Successfully transferred 609c813aedb0d81fb57e.hot-update.json on device emulator-5554.
JS: HMR: Checking for updates to the bundle with hmr hash 609c813aedb0d81fb57e.
JS: HMR: Ignored an update to unaccepted module:
JS: HMR: ➭ ./routes.ts
JS: HMR: ➭ ./main.ts
JS: HMR: Cannot apply update with hmr hash 609c813aedb0d81fb57e.
JS: HMR: Aborted because ./routes.ts is not accepted
JS: Update propagation: ./routes.ts -> ./main.ts
Refreshing application on device emulator-5554...
Successfully transferred bundle.js on device emulator-5554.
Successfully transferred runtime.js on device emulator-5554.
Successfully transferred vendor.js on device emulator-5554.
JS: HMR: Cannot apply update. A previous update aborted. Application needs to be restarted in order to apply the changes.
Restarting application on device emulator-5554...

这会导致整个应用程序重新启动,没有 HRM 更新。

复制

基于 nativescript 博客 NativeScript-Vue with Class Components链接上有更多示例。

  1. npm install -g @vue/cli @vue/cli-init
  2. vue init nativescript-vue/vue-cli-template hmrbug。 (选择 typescript )
  3. npm i vue-class-component
  4. npm i vue-property-decorator

下一步:创建以下模板:

<Label text="Hello" textWrap="true" />

然后在文本中添加一句问候

<Label text="Hello Hello" textWrap="true" />

检查错误。

预期行为

无需重启整个应用程序即可使用著名的 HMR。我认为这是一个严重的问题或错误,因为它会降低开发人员在等待应用程序重启时的工作效率。

最佳答案

请使用tns debug android --no-hmr

在 nativescript-vue 和 HMR 中没有保证。 HMR 只能在更改样式文件时使用。

我个人使用

我仅将 tns debug android 用于样式设置。如果我进行任何其他更改,我不信任 HMR。

我添加了一个名为 yarn devan 的 yarn 脚本来加快输入过程。

我已将以下行添加到我的 package.json 文件中

{
"scripts": {
"dev": "tns debug android",
"devan": "tns debug android --no-hmr",
"devin": "tns debug ios --no-hmr",
"un": "adb uninstall com.domain.yourapp"
},
}

如果您在 nativescript-vue 项目中使用 typescipt 文件,您将始终看到 HMR 错误消息。

JS: HMR: Checking for updates to the bundle with hmr hash 7d5f6392d6103f1496e6.
JS: WARN HMR: Ignored an update to unaccepted module:
JS: WARN HMR: ➭ ./routes/index.ts
JS: WARN HMR: ➭ ./main.ts
JS: ERROR HMR: Cannot apply update with hmr hash 7d5f6392d6103f1496e6.
JS: ERROR HMR: Aborted because ./routes/index.ts is not accepted
JS: Update propagation: ./routes/index.ts -> ./main.ts

关于typescript - Nativescript-vue + Typescript - HMR 不适用于 Vue 类组件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61238619/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com