1
我想導入一個外部js庫,瞬間進入離子2. 我有時刻模塊存儲在節點模塊中,但看起來網絡包不包括它在我的項目目錄中。Ionic2導入外部Js文件
<body>
<!-- Ionic's root component and where the app will load -->
<ion-app></ion-app>
<!-- The polyfills js is generated during the build process -->
<script src="build/polyfills.js"></script>
<!-- The bundle js is generated during the build process -->
<script src="build/main.js"></script>
<script src="node_modules/moment/moment.js"></script>
</body>
然而,當我看着我的瀏覽器,它不包括在該節點模塊
我已經安裝在我的nose_modules時刻然而,當離子建立它不會出現在我的瀏覽器一個文件
我正在使用Ionic 2和Angular 2.我的猜測是,我需要指定包括它如何通過模塊或網絡包沒有人知道如何做到這一點?
**編輯** 這裏是TS頁面類
import { Component } from '@angular/core';
import { NavController, NavParams } from 'ionic-angular';
import { User } from '../../models/user';
import { Users } from '../../providers/users';
import moment from 'moment';
@Component({
selector: 'page-profile',
templateUrl: 'profile.html'
})
export class ProfilePage {
userId: number;
user: User;
getAge =() => {
if (this.user) {
return moment().diff(this.user.birthday, 'years');
}
}
constructor(public navCtrl: NavController, public navParams: NavParams, private usersProvider: Users) {
this.userId = navParams.get('userId');
usersProvider.get(this.userId).subscribe(user => {
this.user = user;
console.log(user)
});
}
ionViewDidLoad() {
console.log('ionViewDidLoad ProfilePage');
}
}
這些文件已經存在,但它們不是從節點提供的。 –
只是刪除你的整個節點模塊文件夾中,之後做這個'故宮i' – Sampath
沒有幫助 –