我正在尝试使用离子2和角度2构建应用程序,当我尝试运行我的应用程序时出现此错误.我建立另一个项目来检查和相同的问题,我真的很困惑这个问题.
这是我的服务代码
import { Injectable } from '@angular/core';
import { Http } from '@angular/http';
import 'rxjs/add/operator/map';
import { Storage} from '@ionic/storage';
import {NavController} from "ionic-angular";
/*
Generated class for the MyService provider.
See https://angular.io/docs/ts/latest/guide/dependency-injection.html
for more info on providers and Angular 2 DI.
*/
@Injectable()
export class MyService {
public local :Storage;
public getsession : any;
constructor(private http: Http, private navCtrl : NavController) {
this.local = new Storage();
console.log("my-service page")
}
postLogin(data){
let link = "http://adirzoari.16mb.com/login.php";
return this.http.post(link,data)
.map(res => …Run Code Online (Sandbox Code Playgroud) 我正在使用firebase phone auth在本机应用程序中使用此文档我在一些不同的设备上测试了它.有时电话验证工作,有时它会抛出此错误
firebase phone auth错误:令牌无效.在nativeToJSError
我是通过firebase的文档做的,并尝试了解这个错误.那是我的代码.
confirmPhone = async (phoneNumber) => {
const phoneWithAreaCode = phoneNumber.replace(/^0+/, '+972');
return new Promise((res, rej) => {
firebase.auth().verifyPhoneNumber(phoneWithAreaCode)
.on('state_changed', async (phoneAuthSnapshot) => {
switch (phoneAuthSnapshot.state) {
case firebase.auth.PhoneAuthState.AUTO_VERIFIED:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
await this.confirmCode(phoneAuthSnapshot.verificationId, phoneAuthSnapshot.code, phoneAuthSnapshot)
res(phoneAuthSnapshot)
break
case firebase.auth.PhoneAuthState.CODE_SENT:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
res(phoneAuthSnapshot)
break
case firebase.auth.PhoneAuthState.AUTO_VERIFY_TIMEOUT:
UserStore.setVerificationId(phoneAuthSnapshot.verificationId)
UserStore.setErrorCodeAuthentication('SMS code has expired')
res(phoneAuthSnapshot)
case firebase.auth.PhoneAuthState.ERROR:
console.log(phoneAuthSnapshot.error.code)
if (phoneAuthSnapshot.error) {
this.showMessageErrorByCode(phoneAuthSnapshot.error.code)
}
rej(phoneAuthSnapshot)
break
}
})
})
}
confirmCode = async (verificationId, code, phoneAuthSnapshot) => {
console.log(verificationId,code); …Run Code Online (Sandbox Code Playgroud) 我希望用户能够选择文本内容(在离子2中),以便他们可以复制它并将其粘贴到其他地方,但似乎已禁用文本选择.用户可以选择输入或文本区域中的文本,但我希望他们能够选择常规内容文本.有没有办法重新启用文本选择?
您好我想通过角度4传递一些参数
APP-routing.module.ts
import { NgModule } from '@angular/core';
import { Routes, RouterModule } from '@angular/router';
import { StartGameComponent } from './start-game/start-game.component';
import { GameComponent } from './game/game.component';
const appRoutes: Routes = [
{ path: '', redirectTo: '/first', pathMatch: 'full' },
{ path: 'startGame', component: StartGameComponent },
{path: 'game/:width/:height',component: GameComponent
}
];
@NgModule({
imports: [RouterModule.forRoot(appRoutes)],
exports: [RouterModule]
})
export class AppRoutingModule {
}
Run Code Online (Sandbox Code Playgroud)
在组件StartGameComponent中
goToGameComponent(width:string,height:string){
this.router.navigate(['game', {width:width,height:height}]);
}
Run Code Online (Sandbox Code Playgroud)
在组件GameComponent中
ngOnInit() {
this.route.params.forEach((urlParams) => {
this.width= urlParams['width'];
this.height=urlParams['height'];
});
Run Code Online (Sandbox Code Playgroud)
在app.component.html中 …
我正在建立一个角度为4和asp.net的网站.
当您进入网站时,您可以看到适合移动尺寸的主页(这就是我想要的).
然后当我导航到订单页面时,它看起来像这样:
订单页面
但是当我从订单页面再次导航回主页时,它会更改屏幕,根本不适合移动设备.
码:
app.component.html
<app-nav_mobile></app-nav_mobile>
<app-header></app-header>
<app-navbar></app-navbar>
<router-outlet> </router-outlet>
<app-footer></app-footer>
Run Code Online (Sandbox Code Playgroud)
nav_mobile.component.html
<div id="preloader" class="signature-dierk">
<div id="status"></div>
</div>
<!-- end : preloader -->
<!-- mobile only navigation : starts -->
<nav class="mobile-nav signature-dierk">
<ul class="slimmenu">
<li><a [routerLink]="['/home']">Home page</a></li>
<li><a [routerLink]="['/order']">orders</a></li>
<li><a href="checkout.html">checout </a></li>
<li><a href="products.html">producst</a></li>
<li><a href="gallery.html">gallery</a></li>
<li><a href="about.html">about</a></li>
</ul>
</nav>
<!-- mobile only navigation : ends -->
Run Code Online (Sandbox Code Playgroud)
home.component.html
<section class="mastwrap signature-dierk">
<div class="inner-wrap">
<section class="intro07 signature-dierk">
<div id="rev_slider_3_1_wrapper" class="rev_slider_wrapper fullscreen-container">
<!-- START REVOLUTION SLIDER 4.6.5 fullscreen mode …Run Code Online (Sandbox Code Playgroud) 我正在使用带有 mobx 的 react js 并从 api 获取数据。我得到的数据是对象数组。当我将数据设置为 mobx 变量时,我会看到代理对象数组(不确定代理说什么)。我只是想将从 api 获得的对象数组设置为 mobx 变量。
我的商店
class UserStore {
@persist @observable token = null
@observable tasks = []
@observable done = false
@persist @observable email = ''
constructor() {
}
@action
getTasks = async () => {
try {
let response = await Api.getTasks()
console.log('getTasks',response.tasks)
this.tasks = response.tasks
console.log('my new tasks',this.tasks)
} catch (e) {
console.log(e)
}
}
Run Code Online (Sandbox Code Playgroud)
正如您在第一个块('black')中看到的那样,我从 api 获取数据,然后我将 respnse.tasks 设置为 this.tasks。
this.tasks = response.tasks
console.log('my new tasks',this.tasks)
Run Code Online (Sandbox Code Playgroud) 我想在Moment.js包中使用我的项目离子2中的日期,我不知道该怎么做,这是链接 时刻js链接
我有datetime变量,我希望它来自我的区域.我应该这样做吗?因为它是在javascript和ionic 2中使用的打字稿
我试图这样做,但它不起作用
constructor(public navCtrl: NavController,private platform:Platform) {
mydate=new Date();
mydate=moment.moment().format('MMMM Do YYYY, h:mm:ss a');
}
Run Code Online (Sandbox Code Playgroud)
当我尝试使用它
let data = moment().format('YYYYMMDD');
let time = moment().format('HHmmss');
console.log('today is: ', data + ' and time: ', time);
Run Code Online (Sandbox Code Playgroud)
我构建反应本机应用程序,我使用scrollView for header与文本列表水平.问题是滚动视图的高度占屏幕的一半大小.即使在宣称它是一种风格之后,它仍然保持原样.
屏幕与scrollView
<View style={Style.container} >
{this.props.ExtendedNavigationStore.HeaderTitle ? <BackHeader header={this.props.ExtendedNavigationStore.HeaderTitle} onPressBack={this.goBack} /> : <Header openDrawer={this.openDrawer} />}
<ScrollView contentContainerStyle={{flexGrow:1}} style={Style.scrollableView} horizontal showsHorizontalScrollIndicator={false}>
{this.renderScrollableHeader()}
</ScrollView>
<Routes /> /* stack with dashboard screen */
</View>
</Drawer>
)
}
Run Code Online (Sandbox Code Playgroud)
款式
import {StyleSheet} from 'react-native'
import {calcSize} from '../../utils'
const Styles = StyleSheet.create({
container : {
flex:1,
backgroundColor:"#e9e7e8"
},
scrollableView:{
height: calcSize(40),
backgroundColor: '#000',
},
textCategory:{
fontSize: calcSize(25),
color:'#fff'
},
scrollableButton:{
flex:1,
margin:calcSize(30)
}
})
export default Styles
Run Code Online (Sandbox Code Playgroud)
正如您所看到的黑色大小是滚动视图,我希望它很小.
在路由堆栈到仪表板屏幕中,样式:
const Style = StyleSheet.create({ …Run Code Online (Sandbox Code Playgroud) 我使用ng服务运行角度4项目,我得到错误
Cannot read property 'length' of undefined
Run Code Online (Sandbox Code Playgroud)
但我的项目中没有任何属性长度..
完整的错误
Your global Angular CLI version (1.2.1) is greater than your local
version (1.1.3). The local Angular CLI version is used.
To disable this warning use "ng set --global warnings.versionMismatch=false".
Cannot read property 'length' of undefined
TypeError: Cannot read property 'length' of undefined
at createSourceFile (E:\?????????\????????? ???\Angular 4\Youtube Channel Angular Firebase\full project of the instructor github\angular-firestarter-master\node_modules\typescript\lib\typescript.js:15457:109)
at parseSourceFileWorker (E:\?????????\????????? ???\Angular 4\Youtube Channel Angular Firebase\full project of the instructor github\angular-firestarter-master\node_modules\typescript\lib\typescript.js:15389:26)
at Object.parseSourceFile (E:\?????????\????????? …Run Code Online (Sandbox Code Playgroud) 我正在开发离子2应用程序.我正在尝试获得高质量的图像,然后将其调整为头像照片.
我的代码:
_FBUserProfile() {
return new Promise((resolve, reject) => {
Facebook.api('me?fields=id,name,email,first_name,last_name,picture.width(600).height(600).as(picture_small),picture.width(360).height(360).as(picture_large)', [])
.then((profileData) => {
console.log(JSON.stringify(profileData));
return resolve(profileData);
}, (err) => {
console.log(JSON.stringify(err));
return reject(err);
});
});
Run Code Online (Sandbox Code Playgroud)
}
但是,照片质量不好,因为我觉得我在这行调整大小时出了问题:
picture.width(600).height(600).as(picture_small),picture.width(360).height(360).as(picture_large)', [])
Run Code Online (Sandbox Code Playgroud)
如何才能获得高质量的照片?
angular ×6
ionic2 ×4
react-native ×2
angular-cli ×1
css ×1
facebook ×1
firebase ×1
html ×1
ionic3 ×1
javascript ×1
mobx ×1
mobx-react ×1
typescript ×1