我正在用Reactjs构建TODO应用程序,在我的components文件夹中,我有一个名为TaskList的类,其中包含以下代码以迭代任务:
import React, { Component } from 'react';
import {connect} from 'react-redux';
class TaskList extends Component {
render(){
return(
<table>
<thead>
<tr>
<th>Tasks</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{this.props.tasks.map((task,index) => <Task key={index} task={task} />)}
</tbody>
</table>
);
}
}
function MapStateToProps(state){
return{
tasks:state.tasks
}
}
export default connect (MapStateToProps)(TaskList);
Run Code Online (Sandbox Code Playgroud)
同样在components文件夹中,我的TaskList类使用了一个名为Task的类:
任务:
import React, {Component} from 'react';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
import {DeleteTask} from '../../redux/actions';
class Task extends Component {
render(){
return(
<tr>
<td>
{this.props.task}
</td> …Run Code Online (Sandbox Code Playgroud) 我正在尝试为我的 React TODO 应用程序创建一个搜索栏。
这是我的 Searchbar 类:
import React, { Component } from 'react';
import { FilterTasks } from '../../redux/actions/searchbar';
import searchreducer from '../../redux/reducers/searchbar';
import {connect} from 'react-redux';
import {bindActionCreators} from 'redux';
class SearchBar extends Component{
constructor(props){
super(props);
this.state = {term: ''};
}
render(){
return(
<div>
<input
className='searchbar'
placeholder="Filter by task"
onChange={term => this.props.FilterTasks(term.target.value)} />
</div>
);
}
}
function MapDispatchToProps(dispatch){
return bindActionCreators({FilterTasks},dispatch);
}
export default connect (MapDispatchToProps)(SearchBar);
Run Code Online (Sandbox Code Playgroud)
这是我的操作:
export const FilterTasks = (filter) => {
return {
type: 'FILTER_TASKS', …Run Code Online (Sandbox Code Playgroud) 我正在尝试从nodeJS本地计算机上的 Sql Server连接。当我运行应用程序时,出现以下错误:
Login failed for user \'admin\'.', code: 'ELOGIN' },
Run Code Online (Sandbox Code Playgroud)
这是我的连接详细信息:
const sql = require('mssql');
const config = {
host:'localhost',
user:'admin',
password:'password',
database:'database',
server:'localhost\\SQLEXPRESS'
}
const poolPromise = new sql.ConnectionPool(config)
.connect()
.then(pool => {
console.log('Connected to localhost '+ config.database +' database');
return pool;
})
.catch(err => console.log('Database connection failed. Error: ', err));
module.exports = {
sql, poolPromise
}
Run Code Online (Sandbox Code Playgroud)
然后在一些 Repository 文件中使用这个 PoolPromise 来管理来自数据库的数据,如下所示:
const { poolPromise } = require('./pool');
module.exports = {
create: async function (name) { …Run Code Online (Sandbox Code Playgroud) 我需要在Windows 10上安装Docker.我读到我只能安装Docker Toolbox.有没有办法让最新的Docker版本而不升级我的电脑到Windows 10专业版?
谢谢
reactjs ×2
docker ×1
ecmascript-6 ×1
frontend ×1
javascript ×1
node.js ×1
react-redux ×1
redux ×1
sql-server ×1
windows ×1