1
我想在我的Ionic2項目中導入json文件。在我home.ts文件我有如何在ionic2中導入json文件
import * as data from '../../assets/i18n/en.json';
在我src文件夾中declarations.d.ts,我有:
declare module '*.json' {
const value: any;
export default value;
}
declare module '*';
當我做「離子起到」我得到了以下錯誤,頁面不會在瀏覽器中加載。
C:\Users\cju\Documents\Projects\Bus-DriverApp-Tabs>ionic serve
> [email protected] ionic:serve C:\Users\cju\Documents\Projects\Bus-DriverApp-Tabs
> ionic-app-scripts serve
[14:20:18] ionic-app-scripts 0.0.45
[14:20:18] watch started ...
[14:20:18] build dev started ...
[14:20:18] clean started ...
[14:20:18] clean finished in 5 ms
[14:20:18] copy started ...
[14:20:18] transpile started ...
[14:20:22] build dev failed: Cannot read property 'indexOf' of undefined
[14:20:22] copy finished in 4.45 s
[14:20:23] watch ready in 4.48 s
[14:20:23] dev server running: http://localhost:8100/
這是我的離子信息。
C:\Users\ccc\Documents\Projects\Bus-DriverApp-Tabs>ionic info
Your system information:
ordova CLI: 6.4.0
Ionic Framework Version: 2.0.0-rc.3
Ionic CLI Version: 2.1.8
Ionic App Lib Version: 2.1.4
Ionic App Scripts Version: 0.0.45
ios-deploy version: Not installed
ios-sim version: Not installed
OS: Windows 7 Node Version: v6.9.1
Xcode version: Not installed
我已經谷歌搜索周圍,但無法解決它。
我想知道如果我可以簡單地只是在我的.ts文件中使用data.some_key將它分配給一個var與設置導入和模塊聲明在我的問題。我不想使用提供者和管道。 –