【问题标题】:nativescript-vue audio module for vue-cli-template用于 vue-cli-template 的 nativescript-vue 音频模块
【发布时间】:2018-10-03 07:27:52
【问题描述】:

我在使用 vue-cli-template 将 nativescript 模块安装到 nativescript-vue 时遇到问题。正如on official website 提到的,我应该通过 npm 安装,然后清理构建。所以我安装了模块:

  npm i --save nativescript-audio
  npm run clean

然后尝试先用“require”实现:

 const audio = require('nativescript-audio');
 const player = new audio.TNSPlayer();

然后用“导入”:

import { TNSPlayer }  from "nativescript-audio";

但我经常遇到同样的错误:

Error: com.tns.NativeScriptException: Failed to find module: "nativescript-audio\options", relative to: app/tns_modules/

完整的日志是here

在 Windows 7 和 Ubuntu 16.04 上试用

这是模块中的问题还是我实现错误?

【问题讨论】:

    标签: npm vue.js nativescript vue-cli


    【解决方案1】:

    正如 nativescript-vue Slack 频道中所讨论的,这是 Windows 问题,应该通过 cli-template 的 webpack 配置来解决。作为一种解决方法,我现在可以通过更改其源代码来导入和使用该插件。 对于 nativescript-audio,我打开了“node_modules/nativescript-audio/audio.android.js”并将路径中的./ 更改为nativescript-audio/

    __export(require("nativescript-audio/options"));
    __export(require("nativescript-audio/android/player"));
    __export(require("nativescript-audio/android/recorder"));
    

    然后npm run cleannpm run watch:android 成功了

    【讨论】:

      猜你喜欢
      • 2019-01-26
      • 2019-09-17
      • 2019-11-02
      • 2019-06-12
      • 2021-04-13
      • 2019-11-23
      • 2021-08-11
      • 1970-01-01
      • 2019-01-17
      相关资源
      最近更新 更多