我点击时试图从状态数组中删除一个项目.目前我有一个onclick监听器,它调用一个传递给道具的函数.但是我得到一个警告:bind():React组件方法可能只绑定到组件实例.请参阅应用程序...并且它不会删除该项目.
感谢您对此问题的任何帮助!它几乎让我的进步陷入停顿.
(function (React) {
var data = [
'Go to work',
'Play Albion Online',
'Keep learning React'
]
var App = React.createClass({
getInitialState: function () {
return {data: []}
},
componentWillMount: function () {
this.state.data = data;
},
removeItem: function (i) {
console.log(i);
},
render: function () {
return (
<ToDoList onRemoveItem={this.removeItem} tasks={this.state.data} />
)
}
});
var ToDoList = React.createClass({
render: function () {
var scope = this;
var tasks = this.props.tasks.map(function (task, i) {
return <ToDo onClick={scope.props.onRemoveItem.bind(this, …Run Code Online (Sandbox Code Playgroud) 我刚刚开始使用node-sass.我已经到了我要求style.css的地步.如果我的stylesheets目录中没有style.css,那么它会为我编译它,但是一旦编译它就不会更新/重新编译更改,直到我手动删除css文件.
任何有关这方面的帮助将非常感激.
app.js
/**
* Module dependencies.
*/
var express = require('express');
var routes = require('./routes');
var user = require('./routes/user');
var http = require('http');
var path = require('path');
var sass = require('node-sass');
var app = express();
// all environments
app.set('port', process.env.PORT || 3000);
app.set('views', path.join(__dirname, 'views'));
app.set('view engine', 'jade');
app.use(express.favicon());
app.use(express.logger('dev'));
app.use(express.json());
app.use(express.urlencoded());
app.use(express.methodOverride());
app.use(app.router);
app.use(express.static(path.join(__dirname, 'public')));
app.use(
sass.middleware({
src: __dirname + '/public/sass', //where the sass files are
dest: __dirname + '/public', //where css should go
debug: true, // obvious …Run Code Online (Sandbox Code Playgroud) 我有一个问题,我已经工作了一段时间,没有真正的进展.我目前正在尝试将我的Shoutcast流加载到我的Web Audio API上下文中.我认为它会违反CORS而我是对的.我尝试了两个XHR请求,然后再通过将音频元素加载到脚本中.它与audio元素一起使用,但在尝试将其加载到脚本时死亡.似乎我唯一的选择是尝试以某种方式将CORS标头添加到我的Shoutcast服务的流中.
我不知道如何做到这一点,并没有运气在线寻找资源.如果有人能给我一些建议,我将不胜感激!
var audioCtx = new (window.AudioContext || window.webkitAudioContext)();
var soundSource, concertHallBuffer;
ajaxRequest = new XMLHttpRequest();
ajaxRequest.open('GET', 'http://127.0.0.1:8000/;stream.mp3', true);
ajaxRequest.responseType = 'arraybuffer';
ajaxRequest.onload = function() {
var audioData = ajaxRequest.response;
console.log(audioData);
audioCtx.decodeAudioData(audioData, function(buffer) {
concertHallBuffer = buffer;
soundSource = audioCtx.createBufferSource();
soundSource.buffer = concertHallBuffer;
soundSource.connect(audioCtx.destination);
soundSource.loop = true;
soundSource.start();
}, function(e){"Error with decoding audio data" + e.err});
}
ajaxRequest.send();
Run Code Online (Sandbox Code Playgroud) 我正在开发一个个人项目,基本上需要一个磁铁链接,开始下载文件,然后在浏览器中显示洪流中的视频.我正在使用名为torrent-stream的npm模块来完成大部分工作.一旦我创建了可读流并开始编写文件,我想通过视频URL向客户端发送套接字消息,以便客户端可以呈现html5视频元素并开始流式传输视频.
我遇到的问题是,一旦客户端呈现视频元素并尝试查找源mp4,我就会在视频文件中找不到404错误.对此的任何建议都将受到高度赞赏.:)
控制器功能:
uploadVideo: function (req, res) {
var torrentStream = require('torrent-stream');
var mkdirp = require('mkdirp');
var rootPath = process.cwd();
var magnetLink = req.param('magnet_link');
var fs = require('fs');
var engine = torrentStream(magnetLink);
engine.on('ready', function() {
engine.files.forEach(function(file) {
var fileName = file.name;
var filePath = file.path;
console.log(fileName + ' - ' + filePath);
var stream = file.createReadStream();
mkdirp(rootPath + '/assets/videos/' + fileName, function (err) {
if (err) {
console.log(err);
} else {
var videoPath = rootPath + '/assets/videos/' + fileName + …Run Code Online (Sandbox Code Playgroud) 我似乎无法使用babel 6 loader和webpack进行编译.这让我很生气.还有其他人遇到过这个问题吗?我不能为我的生活看到我搞砸了.:)
控制台日志
ERROR in ./~/redux/lib/index.js
Module build failed: ReferenceError: [BABEL] /Users/montague/Sites/redux/routing/node_modules/redux/lib/index.js: Unknown option: /Users/montague/Sites/redux/routing/node_modules/redux/.babelrc.stage
at Logger.error (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/logger.js:43:11)
at OptionManager.mergeOptions (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:18)
at OptionManager.addConfig (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:206:10)
at OptionManager.findConfigs (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:347:16)
at OptionManager.init (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:392:12)
at File.initOptions (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/index.js:191:75)
at new File (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/index.js:122:22)
at Pipeline.transform (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/pipeline.js:42:16)
at transpile (/Users/montague/Sites/redux/routing/node_modules/babel-loader/index.js:14:22)
at Object.module.exports (/Users/montague/Sites/redux/routing/node_modules/babel-loader/index.js:83:14)
@ ./src/js/main.js 11:13-29
ERROR in ./~/react-redux/lib/index.js
Module build failed: ReferenceError: [BABEL] /Users/montague/Sites/redux/routing/node_modules/react-redux/lib/index.js: Unknown option: /Users/montague/Sites/redux/routing/node_modules/react-redux/.babelrc.stage
at Logger.error (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/logger.js:43:11)
at OptionManager.mergeOptions (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:245:18)
at OptionManager.addConfig (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:206:10)
at OptionManager.findConfigs (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:347:16)
at OptionManager.init (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/options/option-manager.js:392:12)
at File.initOptions (/Users/montague/Sites/redux/routing/node_modules/babel-core/lib/transformation/file/index.js:191:75) …Run Code Online (Sandbox Code Playgroud) 导入基本组件时,我的webpack崩溃了.我不确定为什么会发生这种情况,但它似乎是ag-grid-react软件包中缺少的lib ...有没有人遇到过这个问题?任何建议都有很大的帮助!
import Table from './components/Table'
Run Code Online (Sandbox Code Playgroud)
在创建Table组件时,它编译好了,但是一旦我像上面那样导入它,它就会崩溃webpack.
// Table.js
import React, { Component } from "react";
import { AgGridReact } from "ag-grid-react";
class Table extends Component {
constructor(props) {
super(props);
this.state = {
columnDefs: this.createColumnDefs(),
rowData: this.createRowData()
};
}
onGridReady(params) {
this.gridApi = params.api;
this.columnApi = params.columnApi;
this.gridApi.sizeColumnsToFit();
}
createColumnDefs() {
return [
{ headerName: "Make", field: "make" },
{ headerName: "Model", field: "model" },
{ headerName: "Price", field: "price" }
];
}
createRowData() {
return [
{ make: "Toyota", …Run Code Online (Sandbox Code Playgroud)