firebase@3.3.0
react-native v0.32在带有wifi的android设备上测试
Firebase数据库没有任何身份验证规则,它是开放式读写.
给定以下文件结构:
|_ firebase.js
|_ actions.js
Run Code Online (Sandbox Code Playgroud)
这不起作用:
firebase.js
import firebase from 'firebase'
const config = {
apiKey: "*****",
authDomain: "****",
databaseURL: "*****",
storageBucket: "*****",
}
firebase.database.enableLogging(true);
export default firebase.initializeApp(config)
Run Code Online (Sandbox Code Playgroud)
actions.js
import firebase from './firebase'
export const fetchData = () => {
const Data = firebase.database().ref('some/data')
Data.on('value', (snapshot) => {
console.log("snapshot", snapshot.val()) // never printed
}, (error) => {
console.error(error)
})
}
Run Code Online (Sandbox Code Playgroud)
调试输出
p:0: Browser went online.
firebase-database.js:36 p:0: Listen called for /some/data default
firebase-database.js:36 p:0: Making …Run Code Online (Sandbox Code Playgroud) firebase react-native firebase-realtime-database react-native-android
我已经做了什么
该应用程序有一个入口点,main.js,它是我的react.js组件和依赖项的捆绑版本,所以我的index.html通常如下所示:
<body>
<script type="text/javascript" src="/static/bundles/main-3997ad3476694c3c91cf.js"></script>
</body>
Run Code Online (Sandbox Code Playgroud)我想做的事
考虑到我的应用程序是单页应用程序,我该如何处理?我不想重新发明轮子也不想复制我的代码.我必须编写什么样的node.js服务器才能实现这种自动服务器端呈现?有没有办法直接在Django中提供服务器端渲染(通过一些工具读取和解释客户端显示的页面的最终结果并返回此原始html?)
python django serverside-javascript single-page-application reactjs
我正在尝试创建一个通用的 React 应用程序(在服务器和客户端上都使用 webpack)并且在导入图像时遇到了困难。我想写这个:
import someImage from './someImage.png'
const SomeImage = () => <img src={someImage}/>
Run Code Online (Sandbox Code Playgroud)
这是我的 webpack 配置文件:
var path = require('path');
var webpack = require('webpack');
var ExtractTextPlugin = require('extract-text-webpack-plugin');
module.exports = {
entry: [
'webpack-dev-server/client?http://127.0.0.1:8080/',
'webpack/hot/only-dev-server',
'./client',
'babel-polyfill'
],
output: {
path: path.join(__dirname, 'dist'),
filename: 'bundle.js'
},
resolve: {
modulesDirectories: ['node_modules', 'shared'],
extensions: ['', '.js', '.jsx']
},
module: {
loaders: [
{
test: /\.jsx?$/,
exclude: /node_modules/,
loaders: ['babel']
},
{
test: /\.css/,
exclude: /node_modules/,
loader: ExtractTextPlugin.extract('style', 'css?modules&importLoaders=1&localIdentName=[name]__[local]___[hash:base64:5]')
},
{ …Run Code Online (Sandbox Code Playgroud) 我想iso-8859-1在python 2.7中用Scrapy抓取一个带有字符集的网页。我在网页上感兴趣的文字是:tempête
Scrapy以UTF8 Unicode返回响应,并带有正确编码的字符:
>>> response
u'temp\xc3\xaate'
Run Code Online (Sandbox Code Playgroud)
现在,我想将该单词写到tempête文件中,所以我要执行以下操作:
>>> import codecs
>>> file = codecs.open('test', 'a', encoding='utf-8')
>>> file.write(response) #response is the above var
Run Code Online (Sandbox Code Playgroud)
当我打开文件时,结果文本为tempête。似乎python无法检测到正确的编码,并且无法读取两个字节编码的char,并认为它是两个单编码的char。
如何处理这个简单的用例?
python ×2
django ×1
firebase ×1
image ×1
javascript ×1
node.js ×1
python-2.7 ×1
react-native ×1
reactjs ×1
scrapy ×1
utf-8 ×1
webpack ×1