小编Jav*_*ner的帖子

拒绝加载字体'data:font/woff .....'它违反了以下内容安全策略指令:"default-src'self'".请注意'font-src'

我的反应webApp在浏览器控制台中提供此错误

Refused to load the font 'data:font/woff;base64,d09........' because it` 
`violates the following Content Security Policy directive: "default-src` `'self'". Note that 'font-src' was not explicitly set, so 'default-src' is used as a fallback.
Run Code Online (Sandbox Code Playgroud)

也:

Refused to connect to 'ws://localhost:3000/sockjs-node/782/oawzy1fx/websocket' because it violates the following Content Security Policy directive: "default-src 'self'". Note that 'connect-src' was not explicitly set, so 'default-src' is used as a fallback.
Run Code Online (Sandbox Code Playgroud)

浏览器控制台截图 在此输入图像描述

index.html有这个元:

<meta http-equiv="Content-Security-Policy" content="img-src 'self' data:; default-src 'self' http://121.0.0:3000/">
Run Code Online (Sandbox Code Playgroud)

WebPack.cofig.js

var debug = process.env.NODE_ENV …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs webpack

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

React-Native Button样式不起作用

Import_this

import {AppRegistry, Text, View, Button, StyleSheet} from 'react-native';
Run Code Online (Sandbox Code Playgroud)

这是我的React Button代码但风格不起作用Hare ...

<Button
  onPress={this.onPress.bind(this)} 
  title={"Go Back"}
  style={{color: 'red', marginTop: 10, padding: 10}}
/>
Run Code Online (Sandbox Code Playgroud)

我也试过这个代码

<Button 
       containerStyle={{padding:10, height:45, overflow:'hidden', 
       borderRadius:4, backgroundColor: 'white'}}
       style={{fontSize: 20, color: 'green'}} 
       onPress={this.onPress.bind(this)} title={"Go Back"}
      > Press me!
</Button>
Run Code Online (Sandbox Code Playgroud)

更新问题:

我也是这样尝试..

<Button
    onPress={this.onPress.bind(this)}
    title={"Go Back"}
    style={styles.buttonStyle}
>ku ka</Button>
Run Code Online (Sandbox Code Playgroud)

样式

const styles = StyleSheet.create({
    buttonStyle: {
        color: 'red',
        marginTop: 20,
        padding: 20,
        backgroundColor: 'green'
    }
});
Run Code Online (Sandbox Code Playgroud)

但没有输出:我的手机截图: - 我的手机截图: -

jsx reactjs react-native react-native-button

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

找不到输入模块:错误:无法解析'./src/index.js'

我安装了一个反应startUpapp并添加了Webpack,但它说 Can't resolve './src/index.js'

浏览器显示
我的应用给了这个样子

我的文件路径和Package.josn它 在此输入图像描述

webpack.config.js文件看:

 var debug = process.env.NODE_ENV !== "production";
    var webpack = require('webpack');
    var path = require('path');

    module.exports = {
        context: path.join(__dirname, "public"),
    devtool: debug ? "inline-sourcemap" : false,
    entry: "./src/index.js",
    module: {
        loaders: [
            {
                test: /\.jsx?$/,
                exclude: /(node_modules|bower_components)/,
                loader: 'babel-loader',
                query: {
                    presets: ['react', 'es2016', 'stage-0'],
                    plugins: ['react-html-attrs', 'transform-decorators-legacy', 'transform-class-properties'],
                }
            }
        ]
    },
    output: {
        path: __dirname + "/public/",
        filename: "build.js"
    },
    plugins: debug ? [] : [
        new webpack.optimize.DedupePlugin(),
        new webpack.optimize.OccurrenceOrderPlugin(), …
Run Code Online (Sandbox Code Playgroud)

javascript reactjs webpack

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

React Rout v-4 `this.props.match.params` **undefined** 和 `staticContext` undefined

我在用

    "react": "^15.6.1",
    "react-dom": "^15.6.1",
    "react-router": "^4.1.2",
Run Code Online (Sandbox Code Playgroud)

野兔我的溃败:

<BrowserRouter>
        <div>
            <Route exact path='/' component={Layout}></Route>
            <Route path='/about' name="about" component={About}>
                <Route path="/:article" component={anotherAbout}></Route>
            </Route>
            <Route path='/protfolio' name="protfolio" component={Portfolio}></Route>
        </div>
    </BrowserRouter >
Run Code Online (Sandbox Code Playgroud)

当我打电话 {this.props.match.params.article}undefined

还有我的控制台: this.props 在此处输入图片说明

为什么staticContext: undefined和我的props.match.params空对象。

javascript reactjs react-router

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

如何使用react Stable版本安装React Native

我尝试使用React Stable版本安装React native,但它安装了React:16-alpha

"dependencies": {
    "react": "16.0.0-alpha.6",
    "react-native": "0.44.0"
}
Run Code Online (Sandbox Code Playgroud)

那么如何使用React Stable版本安装React-native?

javascript reactjs react-native

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