小编Dmi*_*try的帖子

无法安装redux-logger

我正在尝试通过以下操作安装redux-logger:

npm install --save redux-logger
Run Code Online (Sandbox Code Playgroud)

之后我在代码中添加了import logger:

import logger from 'redux-logger'
Run Code Online (Sandbox Code Playgroud)

然后我将记录器包含在applyMiddleware中:

const createStoreWithMiddleware = applyMiddleware(thunk, logger)(createStore)
const reducer = combineReducers(reducers)
const store = createStoreWithMiddleware(reducer, undefined, autoRehydrate())
persistStore(store, persistConfig)
Run Code Online (Sandbox Code Playgroud)

但我得到一个错误,它没有安装.有人知道它为什么会发生吗?

在此输入图像描述

javascript react-native redux react-redux

7
推荐指数
2
解决办法
3148
查看次数

React Native:有没有办法检查文件是否存在于 android_asset 文件夹中?

我需要像这样检查文件夹中的文件是否存在:

file:///android_asset/contents/my.html
Run Code Online (Sandbox Code Playgroud)

我尝试使用 react-native-filesystem 插件

componentWillMount () {
    async function checkIfFileExists() {
      const fileExists = await FileSystem.fileExists('file:///android_asset/contents/my.html')
      console.log(`file exists: ${fileExists}`)
    }
}
Run Code Online (Sandbox Code Playgroud)

我确定 my.html 文件在那里,但我在 fileExists 中得到错误。有人知道如何正确检查吗?

javascript android react-native

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

如何自定义Ant.design样式

谁知道如何以正确的方式自定义Ant.design样式?

例如,我要更改默认的backgroundColor和Header部分的高度:

import React, { Component } from 'react';
import { Form, Layout } from 'antd';
const { Header, Footer, Sider, Content } = Layout;

export default class Login extends Component {

render () {
    return (
        <div>
            <Layout>
                <Header style={{backgroundColor: '#555555', height: '5vh'}}>header</Header>
                <Layout>
                    <Content>main content</Content>
                </Layout>
                <Footer>footer</Footer>
            </Layout>
        </div>
    )
}
}
Run Code Online (Sandbox Code Playgroud)

可以,还是有更好的自定义样式的方法?因为我还没有找到某些组件的属性或smth。像这样。

javascript css reactjs antd

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

我们可以说String是Javascript中的对象吗?

当我听到字符串是JS中的基元时,我总是很困惑,因为每个人都知道字符串具有不同的方法,例如:length,indexOf,search等。

let string = "Please locate where 'locate' occurs!";
let pos = str.lastIndexOf("locate");
let position = str.search("locate");
Run Code Online (Sandbox Code Playgroud)

javascript ecmascript-6

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

jQuery函数.text()的工作不正确

我试图通过使用没有任何标签从HTML获取所有文本$('.container').text().我没有获得明文,而是获得带有重复部分的文本.

这是我的HTML代码:

<div class="v highlighted" id="4">
    <span class="vn" id="4">4</span>
    <span class="p">Text-0</span><br>
    <span class="p">
        <span class="wj">
            Text-1
            <span class="w">Text-2</span>
            Text-3
        </span>
    </span><br>
</div>

<script>
    console.log($(".highlighted :not(.vn)").text());
</script>
Run Code Online (Sandbox Code Playgroud)

在控制台中我看到了这个结果:

Text-0Text-1Text-2Text-3Text-1Text-2Text-3Text-2
Run Code Online (Sandbox Code Playgroud)

有人知道它为什么会发生吗?

javascript jquery

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

看起来像是在使用const的React Native中提升

我注意到一个有趣的东西在本地反应.我认为const和let不支持在ES6中提升.如何在其定义之上使用const 样式?

    render() {
        const { repos } = this.state;
        const reposList = repos.map((rep, index) => {
            return (
                    <Text>{rep.name}</Text>
            )
        });

        return (
                <View style={styles.container}>  <-- styles should not be defined
                    {reposList}
                </View>
        );
    }
}

const styles = StyleSheet.create({
    container: {
        flex: 1,
        justifyContent: 'center',
        alignItems: 'center',
        backgroundColor: '#F5FCFF',
    },
    welcome: {
        fontSize: 20,
        textAlign: 'center',
        margin: 10,
    },
    instructions: {
        textAlign: 'center',
        color: '#333333',
        marginBottom: 5,
    },
});
Run Code Online (Sandbox Code Playgroud)

是因为React Native中的提升机制吗?

javascript ecmascript-6 react-native

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

如何使用 bash 脚本将所有 *.html 文件从一个文件夹复制到另一个文件夹?

我有以下文件夹结构:

..
 documents
    folder_destination  // <- here I want to put *.html files
    project
       scripts
          myScript.sh
       folder_source
          a.html
          b.html
          c.html
Run Code Online (Sandbox Code Playgroud)

我想在 myScript.sh 文件中编写一个 bash 脚本,它将所有 *.html 文件从 folder_source 复制到 folder_destination。

myScript.sh 代码示例:

#!/bin/bash

cd ../folder_source
for f in *.html
do
   cp -v "$f"  ../../folder_destination/"${f%.html}".html
done
Run Code Online (Sandbox Code Playgroud)

但它不起作用

bash

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

React Native:如何将 require(path) 与动态 url 一起使用?

我想使用WebView来显示一些html内容

这是一个例子:

return (
            <WebView
                    style={styles.container}
                    source={source}
                    scalesPageToFit={Boolean(true)}
                    onNavigationStateChange={this._onNavigationStateChange} />
    )
Run Code Online (Sandbox Code Playgroud)

对于源变量,我需要有两个不同的值:

1)对于android平台我需要使用这样的东西:

source = {uri: `file:///android_asset/contents/${languageId}text.html`}
Run Code Online (Sandbox Code Playgroud)

2)对于ios我需要使用smth。像这样:

source = require(`../srv/localization/contents/${languageId}text.html`)
Run Code Online (Sandbox Code Playgroud)

对于android来说它工作得很好,但是对于ios来说它不起作用。这个网址也适用于 iOS

require(`../srv/localization/contents/entext.html`)
Run Code Online (Sandbox Code Playgroud)

据我了解,这是因为动态网址(${languageId}text.html)

问题是iOS如何使用动态url?

javascript require ios react-native

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