小编Khu*_*shi的帖子

在localStorage中存储对象

我有这样一个数组:

[{name:"test", time:"Date 2017-02-03T08:38:04.449Z"}]
Run Code Online (Sandbox Code Playgroud)

我存储它,localstorage当我从中检索数据时localstorage得到了值:

[object, object]
Run Code Online (Sandbox Code Playgroud)

我该如何解决这个问题?

config.ts

import { Injectable } from "@angular/core";

@Injectable()
export class TokenManager {

  public tokenKey: string = 'app_token';

  constructor() { }    

  store(content) {
    var contentData;

    console.log("inside localstorsge store:", content);
    contentData = content.map(
      (data) => data.name
    )
    console.log("contentData:", contentData)
    localStorage.setItem(this.tokenKey, content);
  }

  retrieve() {
    console.log("inside localstorage");
    let storedToken: any = localStorage.getItem(this.tokenKey);
    console.log("storedToken:", storedToken);//====> here this console is[object object]
    if (!storedToken) throw 'no token found';
    return storedToken;
  }

}
Run Code Online (Sandbox Code Playgroud)

javascript typescript angular

31
推荐指数
3
解决办法
4万
查看次数

'Actions'类型中不存在属性'payload'

我是TypeScript和Visual Studio Code的新手.我收到以下错误:

*[ts] Property 'payload' does not exist on type 'Actions'.

我的代码:

action.ts文件:

  import { Action } from '@ngrx/store';
  import { Item } from '../models/list';

  export class AddBookAction implements Action {
      type = ActionTypes.ADD_BOOK;

      constructor(public payload: Item) { }
  }

  export type Actions = AddBookAction;
Run Code Online (Sandbox Code Playgroud)

reducer.ts

import * as list from 'action';

export function reducer(state = initialState, action: list.Actions): State {

switch (action.type) {
    case list.ActionTypes.LOAD: {
      return Object.assign({}, state, {
        loading: true
      });
    }

    case list.ActionTypes.LOAD_SUCCESS: {
      const …
Run Code Online (Sandbox Code Playgroud)

typescript visual-studio-code ngrx

6
推荐指数
1
解决办法
3511
查看次数

如何在操纵up中模拟拖放动作?

我在应用程序中反应了Dnd(拖放)。我想为此进行端到端测试。

我要模拟的是将特定数据拖放到特定位置。如何启用此功能?

我所拥有的是:

test.js

const mouse = page.mouse;
await mouse.down();
await mouse.move(126, 19);
await page.waitFor(400);
Run Code Online (Sandbox Code Playgroud)

使用此代码选择已完成。但拖动不起作用。我应该如何实施呢?

testing reactjs e2e-testing puppeteer

6
推荐指数
3
解决办法
3427
查看次数

反应导航中的自定义抽屉

在我的 React Native 项目中,我有带有 screen1 和 screen2 等屏幕的自定义抽屉。Screen1 用于堆栈导航器,在 Screen 2 中它包含选项卡导航器。如何启用这种嵌套导航。

我正在使用 React navigation 5 来构建自定义抽屉。

这是我的代码:

  import { DrawerContentScrollView, DrawerItem } from "@react-navigation/drawer";
  .............
  render = () => {
    <DrawerContentScrollView {...props}>
    <View style={styles.menuContainer}>
    <View style={[styles.menuItemsCard, { backgroundColor: "#fff2df" }]}>
    <View style={[styles.circleContainer, { backgroundColor: "#FFC56F" }]}>
    <Icon travel name="suitcase" type="font-awesome" color="#fbae41" />
    </View>
            <DrawerItem
             label="Screen1"
             labelStyle={{ color: "#fbae41", fontSize: 10 }}
                            onPress={() => {
                                props.navigation.navigate("PatientInfo");
                            }}
                        />
            </View>
            <View style={[styles.itemCard, { backgroundColor: "#EFFFD5" }]}>
            <View style={[styles.circleContainer, { backgroundColor: "#b5ff39" …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs react-native react-navigation-v5

6
推荐指数
1
解决办法
4万
查看次数

找不到模块“应用程序设置”

尝试包含“应用程序设置模块”时出现错误。

*找不到模块“应用程序设置”<-----错误

错误在我的 storage.driver.ts 中,它位于使用环回 sdk 构建器构建的 nativescript sdk 中

storage.driver.ts

import * as AppSettings from 'application-settings'; <---- Error here
export class StorageDriver {
static set(key: string, value: any) {
AppSettings.setString(key, String(value));
}
static get(key: string): any {
return AppSettings.getString(key);
}
static remove(key: string): any {
if (AppSettings.hasKey(key)) {
  AppSettings.remove(key);
} else {
  console.log('Trying to remove unexisting key: ', key);
}
}
}
Run Code Online (Sandbox Code Playgroud)

我应该怎么做才能解决这个问题?我是 nativescript 的新手。

typescript nativescript angular

3
推荐指数
2
解决办法
2338
查看次数

如何使用angular2在客户端生成rsa密钥对?

我需要知道如何使用 angular2 在客户端生成“rsa”密钥对。我需要生成私钥/公钥对并将私钥保存到数据库中,并希望在客户端内部使用公钥。我该如何实施?

我发现这个https://www.npmjs.com/package/generate-rsa-keypair用于生成密钥对。但它的节点?我可以将它实施到我的客户端吗?如果是如何?有没有其他方法可以实现这一点?

javascript client rsa key-generator angular

3
推荐指数
1
解决办法
3942
查看次数