我的反应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) 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)
我安装了一个反应startUpapp并添加了Webpack,但它说 Can't resolve './src/index.js'
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) 我在用
"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
为什么staticContext: undefined和我的props.match.params空对象。
我尝试使用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?