Ionic 2 CLI构建失败,给出了以下错误:"TypeError:无法读取未定义的属性'AssetUrl'".
两个线程都建议修改"package.json"文件并删除"dependencies"和"devDependencies"中版本前面的"^"符号.
我这样做然后CLI:
我仍然得到同样的错误.
在这个线程的某个时刻,它建议使用一些我不熟悉的npm命令,引用它:"rm -rf node_modules和npm cache clean以及新的npm install".我真的不明白这一切是什么.
如果有人拿出神奇的解决方案来让构建运行正常,我将不胜感激.但我还想了解"TypeError:无法读取未定义的属性'AssetUrl'"是如何与"package.json"链接的?我不明白为什么这个错误会导致这种可能的解决方案.
我的版本是:npm 3.10.3节点6.7.0 cordova 6.3.1离子2.1.0
这是我的package.json,因为它现在看起来更像是在两个线程中操作建议读取:
{
"name": "ionic-hello-world",
"author": "Ionic Framework",
"homepage": "http://ionicframework.com/",
"private": true,
"scripts": {
"build": "ionic-app-scripts build",
"watch": "ionic-app-scripts watch",
"serve:before": "watch",
"emulate:before": "build",
"deploy:before": "build",
"build:before": "build",
"run:before": "build"
},
"dependencies": {
"@angular/common": "2.0.0",
"@angular/compiler": "2.0.0",
"@angular/compiler-cli": "0.6.2",
"@angular/core": "2.0.0",
"@angular/forms": "2.0.0",
"@angular/http": "2.0.0",
"@angular/platform-browser": "2.0.0",
"@angular/platform-browser-dynamic": "2.0.0", …Run Code Online (Sandbox Code Playgroud) 我是离子的新手2.我遇到了一个问题.我使用map定义var map;它在loadMap()函数内部工作得很好.但是,如果我定义地图就像map:any;它不工作.抛出这样的错误.
错误:未捕获(在承诺中):TypeError:undefined不是对象(评估'this.map')
import { Component } from '@angular/core';
import { NavController,Platform } from 'ionic-angular';
import { Geolocation } from 'ionic-native';
import {DataService} from '../../providers/data-service';
declare var L:any;
@Component({
selector: 'page-my-map',
templateUrl: 'my-map.html',
providers:[DataService]
})
export class MyMap {
public data: any;
map:any=null;
markersLayer;
myPositionLayer;
myCircleLayer;
showingon;
LeafIconMe;
LeafIcon;
constructor(platform: Platform, public dataService: DataService) {
platform.ready().then(() => {
Geolocation.getCurrentPosition().then((resp) => {
});
this.loadMap();
this.loadData();
});
}
loadMap(){
this.map = L.map('map', {}).setView([40.980963, 29.0966243], …Run Code Online (Sandbox Code Playgroud) 我正在与Ionic2和Angular2合作开展一个项目.尝试运行时ionic serve,将检索数据而不会出现任何错误.但是,当尝试在ios上运行并运行时ionic build ios,我得到以下编译时错误,该属性不存在.
还有其他人遇到过这个问题吗?
我很感激任何建议.
home.ts
import { Component } from '@angular/core';
import { ProfileService } from './profile.service';
@Component({
selector: 'home',
templateUrl: 'home.html',
providers: [ProfileService]
})
export class HomePage {
constructor(public d: HomeService){
this.loadData();
}
loadData() {
this.d.fbPromise.then( (FB) => this.data.getData(FB)).then(response => {
this.data = response;
});
}
}
Run Code Online (Sandbox Code Playgroud)
home.html的
<ion-header>
<ion-navbar>
<ion-title>Home</ion-title>
</ion-navbar>
</ion-header>
<ion-content>
<div class="profile-content" padding>
<div class="content-header">
<h2 class="name">{{ this.data.name }}</h2>
<div class="interests-content">
<h3>interests</h3>
<span *ngFor="let interest of this.data.interests" >
{{ …Run Code Online (Sandbox Code Playgroud) 我有一个关于处理Firebase中多对多关系的问题.基本上,我正在尝试从Firebase数据中的多个路径构建用户配置文件对象.我已经尝试构建一个返回observable的函数,然后更新该observable中的数据,因为嵌套的observable从Firebase获取数据.
问题是嵌套的observable永远不会被调用,从我所知道的.几个小时以来,我一直在打我的头,没有任何真正的成功.谁能说出我做错了什么?我觉得这是一个很常见的问题,可以解决.
public getUserProfile(data) {
return this._af.database.object(`/social/users/${data.id}`).map((user) => {
for ( let vidKey in user.videos) {
// Once the code hits this line, it never fires at all :(
this._af.database.object(`/social/videos/${vidKey}`).map((video) => {
user.videos[vidKey] = video;
});
}
return user;
});
}
Run Code Online (Sandbox Code Playgroud) firebase firebase-realtime-database ionic2 angularfire2 angular
我试图在输入结束时获得Ionic 2的范围滑块的值.
在doumentation中唯一可用的事件是ionChange,它在输入期间触发多次,我只需要最后一个值来执行操作.
我尝试手动添加touchend事件,但忽略了该事件.
这也是一个问题的普通人.
<ion-range (ionChange)="showVal($event)" (touchend)="presentValue(event)" min="0" max="100" [(ngModel)]="currentTime" color="danger">
<ion-icon small range-left name="sunny"></ion-icon>
<ion-icon range-right name="sunny"></ion-icon>
</ion-range>
Run Code Online (Sandbox Code Playgroud)
有人知道在Ionic 2的范围滑块上收听touchend事件的方法吗?
我知道有通过禁用选项的那些"未使用的导入的警告给tslint运行时,ionic serve或者ionic build.但我不知道该把它放在哪里.有人知道吗?谢谢
[1] https://palantir.github.io/tslint/rules/no-unused-variable/
我是离子2原生的初学者.我使用本教程(http://www.joshmorony.com/ionic-2-how-to-use-google-maps-geolocation-video-tutorial/)创建了一个简单的位置跟踪应用程序,我想自动更新用户当前用户旅行时的位置.我搜索了教程或任何来源以了解这一点.但我找不到任何东西.如果有人知道有关自动更新用户位置的信息,ioinc 2请告诉我如何做到这一点或给我一个链接.
这是我的代码
export class MapPage {
x: number = 0;
y: number = 0;
@ViewChild('map') mapElement: ElementRef;
map: any;
constructor(public navCtrl: NavController) {
this.loadMap();
}
loadMap() {
Geolocation.getCurrentPosition().then((position) => {
let latLng = new google.maps.LatLng(position.coords.latitude, position.coords.longitude);
console.log(position.coords.latitude + " " + position.coords.longitude)
let mapOptions = {
center: latLng,
zoom: 15,
mapTypeId: google.maps.MapTypeId.ROADMAP
}
this.map = new google.maps.Map(this.mapElement.nativeElement, mapOptions);
console.log(this.map);
}, (err) => {
console.log(err);
});
}
addInfoWindow(marker, content) {
let infoWindow = new google.maps.InfoWindow({
content: …Run Code Online (Sandbox Code Playgroud) 我在视图上有一个列表,单击列表中的每个项目都会呈现一个新视图.我希望它从屏幕的右边缘滑动,就像默认的android(我假设).Ionic2中的默认NavControl.push()方法呈现新视图,就像它出现在哪里.从Ionic2文档中可以看出,这可能是可能的(但没有给出示例).从有关NavOptions的文档中,
NavController上的一些方法允许自定义当前转换.为此,我们可以使用修改后的属性传递对象.
属性"动画"理解以下值:md-transition,ios-transition和wp-transition.
任何人都可以解释如何使用这个NavOptions来改变NavController.push()的动画?
我目前正在使用Ionic2和ngrx构建一个应用程序,如果没有网络连接,我试图阻止certian Actions.
有了停止,我的意思是以某种方式使它们对其他效果和商店不可见或阻止它们进一步"传播".
有没有办法做这样的事情?
@Effect()
checkNetworkConnection$ = this.actions$
.ofType(book.ActionTypes.LOAD_BOOKS, book.ActionTypes.CREATE_BOOK)
.if(Network.connection === 'none')
.do(() => new ShowNetworkAlertAction()) //Returns ShowNetworkAlertAction
.stopPropagation(); // Removes the Action from the stream
Run Code Online (Sandbox Code Playgroud)
stopPropagation()应该以某种方式从流中"删除"Action,之后应该就像从未调度过该动作一样.甚至商店也不应该更改任何内容或执行将在此Action上执行的代码.
ionic2 ×10
angular ×8
node.js ×2
angularfire2 ×1
cordova ×1
firebase ×1
geolocation ×1
native ×1
ngrx ×1
npm ×1
range ×1
redux ×1
rxjs ×1
tslint ×1
typescript ×1