[英]Angular import Node Package
我克隆了這個 angular 項目: https : //github.com/etherparty/explorer
我想在其中安裝另一個模塊: https : //github.com/miguelmota/ethereum-input-data-decoder
我現在想在 angular 中使用 npm 包的功能。 它不起作用。
我采取的步驟:
npm install ethereum-input-data-decoder
試過是否有效。 不!
然后我在 transactionInfosController.js 文件的第 1 行添加了導入,因為我想在那里使用新模塊。
import { InputDataDecoder } from '../../ethereum-input-data-decoder';
程序部分崩潰並出現錯誤:
Uncaught SyntaxError: Unexpected token {
我意識到我錯誤地導入了節點包。
但是查看克隆的 git repo 的文件結構,我沒有看到可以導入包的另一個文件。
我到底需要在哪里放置導入/我需要創建哪個文件?
編輯:需要 AngularJS 的答案
你能試試這個嗎:
import * as inputDataDecoder from 'ethereum-input-data-decoder'
或者正如托尼指出的那樣
import InputDataDecoder as inputDataDecoder from 'ethereum-input-data-decoder'
如果您使用 angularjs,請嘗試以下操作:
<script src='path_to_node_modules/ethereum-input-data-decoder'></script>
然后將其導入為:
angular.module('YourApp', ['InputDataDecoder']);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.