【问题标题】:Which package is needed to import vue components?导入vue组件需要哪个包?
【发布时间】:2019-08-14 18:52:15
【问题描述】:

我是 nativescript 和“npm 相关”开发开发的新手,正在尝试创建我的第一个 NativeScript-Vue 应用程序,但遇到了一些麻烦。

1) 首先,当我使用 import Vue from 'nativescript-vue'; 语法而不是 const Vue = require('nativescript-vue'); 时,我得到这样的异常:

    An uncaught Exception occurred on "main" thread.
    java.lang.RuntimeException: Unable to create application 
    com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

    Cannot compile /data/data/org.nativescript.sirius/files/app/main.js

    SyntaxError: Unexpected identifier
    File: "file:///data/data/org.nativescript.sirius/files/app/main.js, 
    line: 1, column: 67

2) 尝试导入 vue 组件(带有 .vue 扩展名)时,甚至找不到它们。

    An uncaught Exception occurred on "main" thread.
    java.lang.RuntimeException: Unable to create application 
    com.tns.NativeScriptApplication: com.tns.NativeScriptException: 

    Error calling module function 

    Error: com.tns.NativeScriptException: Failed to find module: 
    "./components/test", relative to: app/

我想我缺少一些包,但不知道到底是哪个。

这是我的 package.json:

    "nativescript": {
           "id": "org.nativescript.sirius",
            "tns-android": {
               "version": "5.2.1"
        }
     },
   "dependencies": {
           "nativescript-theme-core": "^1.0.4",
           "nativescript-vue": "^1.3.1",
           "tns-core-modules": "^3.4.1"
    },
   "devDependencies": {}

【问题讨论】:

  • 你的依赖似乎很老了,当前的nativescript-vue 版本是v2.2.0tns-core-modulesv5.5.2 上。您是否创建了项目表单官方入门模板?
  • 我在 WebStorm 中安装了 NativeScript 支持插件。 v0.13.0
  • Manoj,谢谢你给我线索。看起来该插件使用旧包创建项目模板。我使用控制台“tns create”命令创建了一个新项目,一切似乎都运行良好。

标签: nativescript nativescript-vue


【解决方案1】:

你的依赖似乎很老了,当前的nativescript-vue 版本是v2.2.0tns-core-modulesv5.5.2 上。

尝试使用官方的入门模板通过 CLI 创建项目。

【讨论】:

    猜你喜欢
    • 2018-11-09
    • 2015-06-26
    • 2021-06-25
    • 1970-01-01
    • 2018-01-16
    • 1970-01-01
    • 2021-02-23
    • 1970-01-01
    • 2019-04-23
    相关资源
    最近更新 更多