0

我正在尝试用 vue 学习 nativescript。我已经了解了 devtools,以及应该有一个 Electron 独立应用程序的事实 npx vue-devtools,但它不会打开任何窗口。尽管 Electron 进程正在产生。

这是一个用 构建的基本应用程序 vue init nativescript-vue/vue-cli-template <name>,所以它应该“开箱即用”,有点。

该应用程序在模拟器和真实设备上都可以正常工作,所以我不知道出了什么问题。我已经多次重新安装并重新启动项目,但没有任何改变。

这是package.json

  "name": "test_devtools",
  "version": "1.0.0",
  "description": "A native application built with NativeScript-Vue",
  "author": "none",
  "license": "MIT",
  "nativescript": {
    "id": "org.nativescript.application",
    "templateVersion": "v2",
    "tns-android": {
      "version": "6.5.0"
    },
    "tns-ios": {
      "version": "6.5.0"
    }
  },
  "dependencies": {
    "@nativescript/theme": "^2.2.1",
    "nativescript-socketio": "^3.3.1",
    "nativescript-toasty": "^3.0.0-alpha.2",
    "nativescript-vue": "^2.6.0",
    "tns-core-modules": "^6.5.1"
  },
  "devDependencies": {
    "@babel/core": "^7.0.0",
    "@babel/preset-env": "^7.0.0",
    "@vue/devtools": "^5.3.2",
    "babel-loader": "^8.1.0",
    "nativescript-dev-webpack": "^1.5.1",
    "nativescript-vue-devtools": "^1.2.0",
    "nativescript-vue-template-compiler": "^2.6.0",
    "nativescript-worker-loader": "~0.11.0",
    "node-sass": "^4.13.1",
    "vue-loader": "^15.9.1"
  }
}

main.js

import Vue from "nativescript-vue";
import App from "./components/App";
Vue.use(VueDevtools);
// Prints Vue logs when --env.production is *NOT* set while building
Vue.config.silent = TNS_ENV === "production";
Vue.config.devtools = true;
new Vue({
  render: (h) => h("frame", [h(App)]),
}).$start();
4

1 回答 1

0

在 main.js 中,您需要先导入 devtools,使其成为第一个导入:

import VueDevtools from 'nativescript-vue-devtools'

然后,在下面(不一定是下一条语句,您可以将其放在文件的较低位置):

if (TNS_ENV !== 'production') {
  Vue.use(VueDevtools)
}

它以这种方式工作。

于 2020-04-19T07:50:31.667 回答