我正在尝试在我的电脑上安装 Angular 5。一切都安装正确,但是当我使用“ng-serve”命令运行我的应用程序时,它显示以下错误。
You are running version v8.7.0 of Node.js, which is not supported by Angular CLI v6.
The official Node.js version that is supported is 8.9 and greater.
Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.
Run Code Online (Sandbox Code Playgroud)
Node.js 的当前版本是“8.7.0”,npm 是“6.0.0”。
经过大量搜索后,我按照以下步骤在 Windows 10 上更新我的 Node.js
npm cache clean -f
npm install -g n
n latest
Run Code Online (Sandbox Code Playgroud)
但我无法使用此命令,它显示以下错误
C:\WINDOWS\system32>npm cache clean -f
npm WARN using --force I sure hope you know what you are doing.
C:\WINDOWS\system32>npm install -g n …Run Code Online (Sandbox Code Playgroud) 我试图在这个链接的帮助下在角度6中做ssr ,但它显示以下错误
Node server listening on http://localhost:4000
TypeError: StaticInjectorError[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
StaticInjectorError(Platform: core)[InjectionToken Application Initializer -> InjectionToken DocumentToken]:
Right-hand side of 'instanceof' is not an object
Run Code Online (Sandbox Code Playgroud)
server.ts
// These are important and needed before anything else
import 'zone.js/dist/zone-node';
import 'reflect-metadata';
import { renderModuleFactory } from '@angular/platform-server';
import { enableProdMode } from '@angular/core';
import * as express from 'express';
import { join } from 'path';
import { readFileSync } from 'fs';
// Faster server renders w/ …Run Code Online (Sandbox Code Playgroud) 我目前在这个问题上花了一天时间,仍然无法从角度5的网址下载文件
leadGenSubmit() {
return this.http.get('http://kmmc.in/wp-content/uploads/2014/01/lesson2.pdf',
{responseType:ResponseContentType.Blob}).subscribe((data)=>{
console.log(data);
var blob = new Blob([data], {type: 'application/pdf'});
console.log(blob);
saveAs(blob, "testData.pdf");
},
err=>{
console.log(err);
}
)
}
Run Code Online (Sandbox Code Playgroud)
当我运行上面的代码时,它显示以下错误
ERROR TypeError: req.responseType.toLowerCase is not a function
at Observable.eval [as _subscribe] (http.js:2187)
at Observable._trySubscribe (Observable.js:172)
Run Code Online (Sandbox Code Playgroud)
如何解决这个问题.任何人都可以发布正确的代码从角度5的网址下载pdf文件?
我在我的angular6应用程序中使用rxjs6间隔。以下是我在angular6应用程序中实现间隔的代码。
app.component.ts
import { interval } from 'rxjs/observable/interval';
const source = interval(1000);
const subscribe = source.subscribe(val => console.log(val));
Run Code Online (Sandbox Code Playgroud)
一切正常,但是如何停止这个间隔?当我尝试取消订阅angular时说 source.unsubscribe is not a function
我正在尝试使用angular 6做简单的redux应用程序。
减速器
import { login,logout } from '../actions/actions';
export interface appReducer {
login:boolean,
user:String
}
const initialstate:appReducer={
login:false,
user:'guest'
}
export function reducer(state=initialstate,action):appReducer {
switch(action.type) {
case login:
return {...state,login:true,user:action.payload}
case logout:
return {...state,login:false,user:action.payload}
}
return state;
}
Run Code Online (Sandbox Code Playgroud)
动作
export const login="LOGIN";
export const logout="LOGOUT"
Run Code Online (Sandbox Code Playgroud)
索引
import { reducer,appReducer } from './reducer';
import { ActionReducerMap } from '@ngrx/store';
interface appState {
appReducer:appReducer;
}
export const reducers:ActionReducerMap<appState>= {
appReducer:reducer
}
Run Code Online (Sandbox Code Playgroud)
records.service.ts
import { Injectable } from '@angular/core';
import { HttpClient,HttpHeaders …Run Code Online (Sandbox Code Playgroud) 我有一个父视图容器,它包含另一个具有两个按钮组件的视图。我需要在按钮组件之间留出一个空间,因为我将 justify-content 添加到子视图容器中,但它不起作用。
代码
import React,{Component} from 'react';
import { View,Image,StyleSheet,Dimensions } from 'react-native';
import { Card,Button,Avatar } from 'react-native-elements';
import Icon from 'react-native-vector-icons/FontAwesome';
export default class WelcomePage extends Component {
render() {
const {navigate}=this.props.navigation
return (
<View style={{flexDirection:'column',flex:1,alignItems:'center',justifyContent: 'flex-start'}}>
<Avatar
width={Dimensions.get('window').width}
containerStyle={{flex:85}}
avatarStyle={{flex:85}}
imageProps={{resizeMode:'cover'}}
source={require('../assets/images/logo.png')}
onPress={() => console.log("Works!")}
activeOpacity={0.7}
/>
<View style={{flexDirection:'row',flex:15,marginTop:10,justifyContent:'space-between'}}>
<Button large title='LOGIN' icon={<Icon name="user-secret" size={25} color="white" />} buttonStyle={{height:50,width:130,backgroundColor:"#b3b3b3"}} titleStyle={{fontWeight:"700"}} containerViewStyle={{borderRadius:5}} borderRadius={5} />
<Button large title='REGISTER' icon={<Icon name="user-plus" size={25} color="white" />} buttonStyle={{height:50,width:130,backgroundColor:"#b3b3b3"}} titleStyle={{fontWeight:"700"}} onPress={() => navigate('register')} containerViewStyle={{borderRadius:5}} …Run Code Online (Sandbox Code Playgroud) 我试图通过遵循此链接来创建角度为6的通用应用程序。完成链接中提到的步骤后,我尝试构建通用应用程序,但显示以下错误。
Project 'testapp' could not be found in workspace.
Error: Project 'testapp' could not be found in workspace.
Run Code Online (Sandbox Code Playgroud)
谁能帮我解决这个问题?
我正在使用redux和react-redux来改变我的应用程序的状态.
我有两个组件,Login和Home.
如果用户正确登录并导航到Home组件,我将调度一个动作来更新状态.我在Home组件路径中使用authguard 来检查用户是否已记录.
但是当我Home通过在地址栏中键入路由导航到组件时,页面将刷新,状态将更改为其初始值.
即使使用地址栏导航到组件,如何维护状态值?
我是 react-native 的新手,我正在尝试使用 react-native 元素 1.00 beta4 中的所有输入组件创建一个简单的页面。我的问题是即使父视图 flexdirection 在 'row '。
注册.js
import React,{ Component } from 'react';
import { Field,reduxForm } from 'redux-form';
import { View,Button } from 'react-native';
import {Icon,CheckBox,Text,Input} from 'react-native-elements';
const renderField=({label,keyboardType,name,icon,iconType}) => {
return(
<View style={{flexDirection:'row'}}>
<Input placeholder={label} inputContainerStyle={{borderWidth:2,borderColor:'lightgrey',borderRadius:20}} inputStyle={{color:'grey'}} leftIcon={<Icon size={25} type={iconType} name={icon} color="grey" />} errorStyle={{fontSize:15}} errorMessage="error" />
</View>
)
}
const checkBoxField=({label,keyboardType,name}) => {
return(
<View style={{flexDirection:'row'}}>
<Text>{label}</Text>
<CheckBox title='Male' checkedIcon='dot-circle-o' uncheckedIcon='circle-o' checked={true} containerStyle={{backgroundColor:'transparent'}} />
</View>
)
}
const RegisterForm=props => { …Run Code Online (Sandbox Code Playgroud) angular6 ×3
angular5 ×2
react-native ×2
angular ×1
javascript ×1
react-redux ×1
react-router ×1
reactjs ×1
redux ×1