每当我webpack
在终端跑步时,我得到:
Hash: efea76b1048c3a97b963
Version: webpack 1.12.13
Time: 33ms
+ 1 hidden modules
ERROR in Cannot find module 'babel-core'
Run Code Online (Sandbox Code Playgroud)
这是我的webpack.config.js文件
module.exports = {
entry: './app-client.js',
output: {
filename: 'public/bundle.js'
},
module: {
loaders: [
{
exclude: /(node_modules|app-server.js)/,
loader: 'babel'
}
]
}
}
Run Code Online (Sandbox Code Playgroud)
的package.json
{
"name": "react",
"version": "1.0.0",
"description": "React polling app",
"main": "app-client.js",
"dependencies": {
"babel-loader": "^6.2.2",
"bootstrap": "^3.3.6",
"express": "^4.13.4",
"react": "^0.14.7"
},
"devDependencies": {},
"scripts": {
"test": "echo \"Error: no test specified\" && …
Run Code Online (Sandbox Code Playgroud) 刚开始使用Node.js. 在我的app/js
文件中,我正在做这样的事情:
app.js
var http = require('http');
http.createServer(function (request, response) {
response.writeHead(200, {'Content-Type': 'text/plain'});
response.end('Am I really running a server?!');
}).listen(8080, '127.0.0.1');
console.log('running server!');
Run Code Online (Sandbox Code Playgroud)
当我在我的终端并运行时node app.js
,控制台吐出'running server!'
,但在我的浏览器中,我得到了,Uncaught ReferenceError: require is not defined
.
有人可以向我解释为什么在终端中,它可以正常工作,但在浏览器中,它不是吗?
我正在使用节点http-server
来为我的页面提供服务.
我正在尝试使用flask创建一个联系表单,但在呈现页面时不断收到此错误.
'forms.ContactForm object' has no attribute 'hidden_tag'
Run Code Online (Sandbox Code Playgroud)
这是我的文件:
contact.html
{% extends "layout.html" %}
{% block content %}
<h2>Contact</h2>
<form action="{{ url_for('contact') }}" method=post>
{{ form.hidden_tag() }}
{{ form.name.label }}
{{ form.name }}
{{ form.email.label }}
{{ form.email }}
{{ form.subject.label }}
{{ form.subject }}
{{ form.message.label }}
{{ form.message }}
{{ form.submit }}
</form>
{% endblock %}
Run Code Online (Sandbox Code Playgroud)
forms.py
from flask.ext.wtf import Form
from wtforms import Form, TextField, TextAreaField, SubmitField, validators
class ContactForm(Form):
name = TextField("Name", [validators.Required()])
email = TextField("Email",[validators.Required(), validators.email()]) …
Run Code Online (Sandbox Code Playgroud) 我的项目中有一个图像文件夹create-react-app
,里面有一堆图像。我想显示组件中的每个图像。
??? Components
? ??? Icons
? ? ??? Icon.jsx (I want to display every single icon)
?
?
??? Images
? ??? Icons
? ? ??? ... (over 100 SVG icons)
Run Code Online (Sandbox Code Playgroud)
在我的 .jsx 文件中,我想遍历每个图像/图标并显示它。
Icons.jsx
import React, { Component } from 'react';
import Icons from '../../Images/Icons';
class Icons extends Component {
render() {
return (
//Loop over every icon and display it
);
}
}
Run Code Online (Sandbox Code Playgroud) 我正在使用flask向在联系页面中提交表单的用户发送电子邮件。
我尝试自己进行测试,即使我填写了整个表格。每当我点击提交时,都会收到一个验证错误,提示我必须填写表格。在我的日志中,它说我得到200分,这意味着该帖子获得了成功。
这是代码:
route.py
from flask import Flask, render_template, request, flash
from forms import ContactForm
from flask.ext.mail import Message, Mail
mail = Mail()
app = Flask(__name__)
app.secret_key = 'development key'
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_PORT"] = 465
app.config["MAIL_USE_SSL"] = True
app.config["MAIL_USERNAME"] = 'contact@gmail.com'
app.config["MAIL_PASSWORD"] = '*********'
mail.init_app(app)
app = Flask(__name__)
app.secret_key = 'development key'
@app.route('/contact', methods=['GET', 'POST'])
def contact():
form = ContactForm()
if request.method == 'POST':
if form.validate() == False:
flash('All fields are required.')
return render_template('contact.html', form=form)
else:
msg = Message(form.subject.data, …
Run Code Online (Sandbox Code Playgroud) 想要在我的模板中直接显示 html 标记。
这是我正在编写要显示的 html 代码的文件。我想显示所有的 html 元素。
import React from 'react';
const html = (
<div>
<ul>
<li>1</li>
<li>2</li>
<li>3</li>
</ul>
</div>
);
export default html
Run Code Online (Sandbox Code Playgroud)
组件文件
import React, { Component } from 'react';
import html from './code/htmlCodeSnippet';
...
render() {
return (
<div>
{html}
</div>
)
}
}
Run Code Online (Sandbox Code Playgroud)
我正在导入要在我的组件中显示的 html 文件。我将使用 html 荧光笔来显示代码。
每当我引用 时{html}
,它都不会显示所有 html 元素。它只是显示为
1
2
3
Run Code Online (Sandbox Code Playgroud) 我想要一个从的中心开始div
而不是从的左上角开始的扩展半径div
。
想象一下,按钮有一个向外跳动的轮廓。该脉动轮廓应该从中间开始div
,然后向外走。
在此处查看示例:https : //jsbin.com/dinehoqaro/edit?html,css,output
您可以看到扩展从左上方开始。
.circle {
background-color: white;
border: 1px solid red;
border-radius: 50%;
width: 50px;
height: 50px;
animation: pulse 1s infinte;
-webkit-animation: pulse 1.2s infinite;
}
button {
background-color: green;
border: none;
border-radius: 50%;
width: 50px;
height: 50px;
}
@-webkit-keyframes pulse {
from {
width: 50px;
height: 50px;
}
to {
width: 100px height: 100px;
}
}
@keyframes pulse {
from {
width: 50px;
height: 50px;
}
to {
width: …
Run Code Online (Sandbox Code Playgroud)我是新来的反应者,我想为应用程序的主屏幕做一些基本的事情。
我想在给定段落中使用给定数组每1.5秒更改最后一个文本。稍后我将添加一些动画,但是现在我只想做基础。
在我的react组件中,我有这样的东西:
import React, { Component } from 'react';
import './Home.css';
class Home extends Component {
render() {
let textArray = ['eat', 'sleep', 'drink', 'snore', 'foo', 'buzz', 'whatever'];
let textThatChanges;
for (var i = 0; i < textArray.length; i++) {
textThatChanges = textArray[i];
}
return (
<section>
<h1>Hello, my name is Barry Allen</h1>
<p>I like to <span> {textThatChanges}</span></p>
</section>
);
}
}
export default Home;
Run Code Online (Sandbox Code Playgroud)
在普通的jQuery中,它看起来像下面的东西:
import React, { Component } from 'react';
import './Home.css';
class Home extends Component …
Run Code Online (Sandbox Code Playgroud)