小编gli*_*a93的帖子

无法获得未知属性“manifestOutputDirectory”

我正在尝试使用 Android Studio“制作项目”,但出现此错误:

任务“:myApp:processGoogleDebugManifest”执行失败。

无法获取类型为 com.android.build.gradle.tasks.ProcessMultiApkApplicationManifest 的任务“:myApp:processGoogleDebugManifest”的未知属性“manifestOutputDirectory”。

请问有什么帮助吗?

编辑:此错误发生在我更新到 gradle v6.5 和插件 v4.1.0 之后。如果我恢复到 gradle v6.1.1 和插件 v4.0.0,错误就会消失。

android android-studio react-native huawei-mobile-services

35
推荐指数
2
解决办法
7082
查看次数

React 中的事件驱动方法?

我想在一个组件中“触发一个事件”,让其他组件“订阅”该事件并在 React 中做一些工作。

例如,这是一个典型的 React 项目。

我有一个模型,从服务器获取数据,并且使用该数据呈现多个组件。

interface Model {
   id: number;
   value: number;
}

const [data, setData] = useState<Model[]>([]);
useEffect(() => {
   fetchDataFromServer().then((resp) => setData(resp.data));
}, []);

<Root>
   <TopTab>
     <Text>Model with large value count:  {data.filter(m => m.value > 5).length}</Text>
   </TobTab>
   <Content>
      <View>
         {data.map(itemData: model, index: number) => (
            <Item key={itemData.id} itemData={itemData} />
         )}
      </View>
   </Content>
   <BottomTab data={data} />
</Root>
Run Code Online (Sandbox Code Playgroud)

在一个子组件中,可以编辑和保存模型。

const [editItem, setEditItem] = useState<Model|null>(null);
<Root>
   <TopTab>
     <Text>Model with large value count:  {data.filter(m => m.value > 5).length}</Text>
   </TobTab>
   <ListScreen> …
Run Code Online (Sandbox Code Playgroud)

event-driven reactjs react-native react-hooks

10
推荐指数
2
解决办法
4330
查看次数

如何正确使用“next-redux-wrapper”与“Next.js”、“Redux-ToolKit”和 Typescript?

我在 Next.js 应用程序中使用 RTK(redux-toolkit)。我正在尝试在“getInitialProps”内调度 AsyncThunk Action。在搜索时,我发现了一个名为“next-redux-wrapper”的包,它公开了“getInitialProps”内的“store”,但我正在努力弄清楚如何使其与我的项目一起使用。

这是该项目的准系统示例,我目前正在使用带有 2 个减速器的 Typescript。一种减速器使用 AsyncThunk 从 API 获取数据。我已经安装了“next-redux-wrapper”,但我不知道如何实现它,以便所有页面都可以访问“getInitialProps”内的“store”。该包的文档有一个示例,但相当令人困惑。

这是我的 store.ts 的样子......

import { Action, configureStore, ThunkAction } from '@reduxjs/toolkit';
import { createWrapper, HYDRATE } from 'next-redux-wrapper';
import { counterReducer } from '../features/counter';
import { kanyeReducer } from '../features/kanye';

export const store = configureStore({
  reducer: {
    counter: counterReducer,
    kanyeQuote: kanyeReducer,
  },
});

export type AppDispatch = typeof store.dispatch;
export type RootState = ReturnType<typeof store.getState>;
export type AppThunk<ReturnType = void> = ThunkAction<
  ReturnType,
  RootState,
  unknown,
  Action<string> …
Run Code Online (Sandbox Code Playgroud)

typescript redux redux-thunk next.js redux-toolkit

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

如何使用类装饰器将装饰器应用于所有类方法

我正在使用实验性打字稿装饰器来管理 Express 中的访问控制。

class AccountController extends Controller {
  
  login(req: Request, res: Response) {
    const { email, password } = req.body;
    const token = await this.model.login(email, password);
    return res.json({
      token
    });
  }

  @hasRole('ADMIN')
  list(req: Request, res: Response) {
    res.json({
      data: await this.model.findAll()
    });
  }
}

Run Code Online (Sandbox Code Playgroud)

hasRole方法装饰器工作正常,我对此很满意。

实现ControllerREST 方法:

class Controller {
  list(req: Request, res: Response) { // impl }
  get(req: Request, res: Response) { // impl } 
  create(req: Request, res: Response) { // impl }
  update(req: Request, res: …
Run Code Online (Sandbox Code Playgroud)

javascript decorator typescript

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

允许使用 ?. eslint 中的语法

我用了?语法在我的代码中,但是当我将 eslint 配置到我的项目中时,他们将此类结构标记为解析错误(意外标记) const currentFiles = folder?.files

这是我的 eslint 配置

{
    "extends": ["airbnb", "prettier"],
    "plugins": ["prettier"],
    "rules": {
      "prettier/prettier": ["error"],
      "react/react-in-jsx-scope": "off",
      "import/no-unresolved": "off",
      "react/jsx-filename-extension": [1, { "extensions": [".js", ".jsx"] }],
      "jsx-a11y/label-has-associated-control": ["error", {
        "required": {
          "some": ["nesting", "id"]
        }
      }],
      "jsx-a11y/label-has-for": ["error", {
        "required": {
          "some": ["nesting", "id"]
        }
      }]
    }
  }
Run Code Online (Sandbox Code Playgroud)

有没有办法以某种方式配置linter,这样就不会再出现任何错误了?

javascript reactjs eslint

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

React中如何根据屏幕宽度进行条件渲染?

有一个问题,我不知道如何在技术上正确地实现该组件。我想根据设备屏幕对元素进行条件渲染。示例:如果屏幕小于 700 px,则我得出一个结论,如果大于,则得出第二个结论

if(window.innerWidth > 700) {
   return(
    <Content>
       1 
    </Content>)
};
return (
<Content>
       2
</Content>)
Run Code Online (Sandbox Code Playgroud)

我使用react、next js和typeScript技术

这个怎么做?

reactjs conditional-rendering responsive

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

为什么 iconv 在 php:7.4-fpm-alpine docker 中返回空字符串

给出以下代码:

\n
<?php\n$mb_name = "\xe6\xb9\x8a\xe5\xb4\x8e \xe7\xb4\x97\xe5\xa4\x8f";\n$tmp_mb_name = iconv(\'UTF-8\', \'UTF-8//IGNORE\', $mb_name);\nif($tmp_mb_name != $mb_name) {\n    echo "tmp_mb_name: {$tmp_mb_name}\\n";\n    echo "mb_name: {$mb_name}\\n";\n    exit;\n} else {\n    echo "no problem!\\n";\n}\n
Run Code Online (Sandbox Code Playgroud)\n

我在3v4l.org中测试并输出no problem!

\n

然而,在php:7.4-fpm-alpine docker图像中,它输出以下内容:

\n
tmp_mb_name: \nmb_name: \xe6\xb9\x8a\xe5\xb4\x8e \xe7\xb4\x97\xe5\xa4\x8f\n\n
Run Code Online (Sandbox Code Playgroud)\n

根据php.net

\n
\n

如果附加字符串 //IGNORE,则无法在目标字符集中表示的字符将被默默丢弃。

\n
\n

为什么无法在 php alpine 图像中$mb_name表示?UTF-8

\n

php encoding character-encoding iconv docker

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

树结构的打字稿接口

我想为树结构定义一个接口。

每个节点可以有零个或多个子节点:

export interface TreeNode {
  children?: Array<TreeNode>;
}
Run Code Online (Sandbox Code Playgroud)

我已经为TreeNodes实现了一个遍历函数。

export function traverseTree(treeData: Array<TreeNode> | TreeNode, callback: (treeNode: any) => any) {
  // implementation omitted
}
Run Code Online (Sandbox Code Playgroud)

我想测试一下。代码如下:

const treeData = [
  {
    name: "root_1",
    children: [
      {
        name: "child_1",
        children: [
          {
            name: "grandchild_1"
          },
          {
            name: "grandchild_2"
          }
        ]
      }
    ]
  },
  {
    name: "root_2",
    children: []
  }
];
const traversingHistory = [];
const callback = (treeNode: any) => {
  traversingHistory.push(treeNode.name);
}
traverseTree(treeData, callback);
Run Code Online (Sandbox Code Playgroud)

但是,编译失败,因为treeData的类型参数不能应用于 …

javascript tree interface typescript

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

css 中的 Angular 内联资源作为 data-uri

在 Angular 应用程序中有没有什么方法可以在不弹出 webpack 配置的情况下拥有内联资源,如 CSS 背景属性中的 SVG?

我已经尝试过自定义 webpack 构建器来删除内置的文件加载器规则并添加 uri-loader,但是,SVG 没有内联。

我怀疑它可能与使用 postcss 的内部 SCSS/CSS 处理有某种关系。

webpack angular-cli angular webpack-4 angular-builder

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

MongoDB-Community 未在 Mac 上启动并出现错误

我写信是为了通知我一段时间前使用 brew (High Sierra) 安装了 mongodb-community 并且它正在运行。然后最近我升级了,它似乎没有连接起来。当我在终端中运行 mongo 时,出现错误:

MongoDB shell version v4.4.0
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed: SocketException: Error connecting to 127.0.0.1:27017 :: caused by :: Connection refused :
connect@src/mongo/shell/mongo.js:362:17
@(connect):2:6
exception: connect failed
exiting with code 1
Run Code Online (Sandbox Code Playgroud)

当我检查启动 mongodb-community 服务的日志时,出现以下错误:

{"t":{"$date":"2020-09-04T21:01:35.015-07:00"},"s":"W",  "c":"CONTROL",  "id":20698,   "ctx":"main","msg":"***** SERVER RESTARTED *****","tags":["startupWarnings"]}
{"t":{"$date":"2020-09-04T21:01:35.021-07:00"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-04T21:01:35.027-07:00"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-04T21:01:35.027-07:00"},"s":"I", …
Run Code Online (Sandbox Code Playgroud)

macos homebrew mongodb

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