小编Par*_*eep的帖子

如何实现 MAT_DIALOG_DEFAULT_OPTIONS?

在一个项目中,我们有多个 Dialog。现在,我想为 DialogOption 设置相同的全局变量。

我发现:https : //material.angular.io/components/dialog/overview 和这段代码:

@NgModule({
  providers: [
    {provide: MAT_DIALOG_DEFAULT_OPTIONS, useValue: {hasBackdrop: false}}
  ]
})
Run Code Online (Sandbox Code Playgroud)

我将这些代码与其他代码一起应用,但它不起作用。根本不应用这些设置。

有人让这些设置工作吗?

angular-material2 angular

12
推荐指数
2
解决办法
7826
查看次数

Heroku运行显示更新,是否需要更新?如果是,那么如何?

heroku run rails console

?    heroku-cli: update available from 6.11.17 to 6.14.16-9ae58fc

?    No app specified
Run Code Online (Sandbox Code Playgroud)

如何更新我的heroku-cli版本?

heroku updates

11
推荐指数
1
解决办法
4827
查看次数

按值过滤对象键并映射到数组

我正在创建一个有角度的应用程序,并且有带有复选框的项目。当用户单击复选框时,我会将选中的项目记录到对象中。该对象看起来像这样:

{1: false, 7: true, 8: true};
Run Code Online (Sandbox Code Playgroud)

When a user clicks on the delete button I need to get only selected items ids.

So I need to filter objects by values and as a result, get an array of integers.

I tried the following code with the lodash library:

console.log(_.pick(this.selectedItems, _.identity));

return _.pick(this.selectedItems, function (value, key) {
        return value;
      });
Run Code Online (Sandbox Code Playgroud)

But this returns an empty array.

What I need to get is an array [7,8]

What is wrong with my …

javascript lodash

8
推荐指数
1
解决办法
88
查看次数

如何在Android Studio中创建目录文件夹

我在这里使用Android Studio,我想在lib文件夹中创建一个目录文件夹。我右键单击lib文件夹,但未显示目录选项。谁能建议我如何在文件夹内创建目录文件夹? 在此处输入图片说明

ide android-studio flutter

5
推荐指数
6
解决办法
2388
查看次数

如何使用 React/Redux 获取登录用户的用户名(或任何其他数据)

存储用户登录数据(主要是用户名或 uuid)的最佳且安全的方法是什么。那么,我可以在其他组件中使用它吗?我想了几种方法来做到这一点。

  1. 登录/注册时,将用户名存储在本地存储中,并在身份验证结束时将其删除。(非常容易实现,但很可能是最不安全的)
  2. 通过 AuthLogin/AuthSignup 方法传递电子邮件,但我似乎不知道如何通过路由器传递电子邮件。我还注意到,如果浏览器刷新,即使用户仍然登录,这也不起作用。
  3. Cookies(还不知道如何在 React 中使用它们)。

我的 authLogin 方法:


export const authLogin = (email, password) => {
    return dispatch =>{
        dispatch(authStart());
        axios.post('http://127.0.0.1:8000/rest-auth/login/',{
            email: email,
            password: password,

        })
        .then(res => {
            const token = res.data.key;
            const expirationDate = new Date(new Date().getTime() + 3600 * 1000);
            localStorage.setItem('token',token);
            localStorage.setItem('expirationDate',expirationDate)
            localStorage.setItem('email', email)#method 1
            console.log("My token",localStorage.getItem('token'))
            dispatch(authSuccess(token,email));#method 2
            dispatch(checkAuthTimeout(3600));
        })
        .catch(err => {
            dispatch(authFail(err))
        })
    }
}
Run Code Online (Sandbox Code Playgroud)

javascript reactjs redux

5
推荐指数
1
解决办法
6062
查看次数

React-picky:元素类型无效:需要一个字符串(对于内置组件)或一个类/函数(对于复合组件),但得到:未定义

我正在使用react-picky包来显示带有typescript的选择过滤器选项,您可以检查以下package.json的版本。当我在没有打字稿的情况下使用 create-react-app 时,一切正常。也许某些库发生了冲突。我尝试过更新react和react-dom,即使它显示与我所附图像相同的错误。这不是一个进出口问题。我已经尝试了所有导入导出的方法。

这是控制台快照 包.json

 {
  "name": "user-portal-client",
  "version": "1.0.0",
  "description": "Front-end code for the Coinstash user portal.",
  "scripts": {
    "start": "webpack-dev-server --open",
    "start:headless": "webpack-dev-server --host 0.0.0.0 --port 5000 --watch-poll",
    "build": "webpack --config webpack.config.prod.js",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "devDependencies": {
    "@types/axios": "^0.14.0",
    "@types/classnames": "^2.2.7",
    "@types/history": "^4.7.0",
    "@types/react": "^16.4.18",
    "@types/react-dom": "^16.0.9",
    "@types/react-modal": "^3.8.1",
    "@types/react-places-autocomplete": "^7.2.3",
    "@types/react-router-dom": "^4.3.1",
    "@types/react-share": "^2.1.1",
    "@types/react-sidebar": "^3.0.0",
    "@types/socket.io-client": "^1.4.32",
    "@types/styled-components": "4.1.8",
    "@types/url-join": "^4.0.0",
    "awesome-typescript-loader": "^5.2.1",
    "copy-webpack-plugin": "^4.4.2",
    "source-map-loader": "^0.2.4",
    "styled-components": "^4.2.0",
    "ts-node": …
Run Code Online (Sandbox Code Playgroud)

typescript reactjs

5
推荐指数
0
解决办法
468
查看次数

如何检查python中是否存在文件?

我正在尝试制作一个 python 脚本来在一个每天都有条目的 excel 文件中创建条目。我想检查一个文件是否存在然后打开它。如果文件不存在,那么我想创建一个新文件。

if have used os path exists 查看文件是否存在

     workbook_status = os.path.exists("/log/"+workbookname+".xlxs")
     if  workbook_status = "True":
     # i want to open the file
     Else:
     #i want to create a new file
Run Code Online (Sandbox Code Playgroud)

python excel

-2
推荐指数
1
解决办法
1万
查看次数