The \\\'Access-Control-Allow-Origin\\\' header contains multiple values \\\'http://localhost:5000, *\\\', but only one is allowed. Origin \\\'http://localhost:5000\\\' is therefore notallowed access.

在iis中父级和子应用同时配置了Access-Control-Allow-Origin = * 响应头。删除任意一个配置就可以了。

2018-10-19 16:04:00   Visit  2
mapOption = { {
        portalItem: { // autocasts as new PortalItem()
            portal: {
                url: \"https://localhost/portal/\"
            },
            id: \"e487c8e548a4474e8ff161563568aa98\"
        }
    }
}

// then we load a web map
var map = new Map(mapOption);
// and we show that map in a container w/ div
var view = new View(Object.assign({
            map: map,
            container: container
        }, viewOption));
2018-10-19 10:50:50   Visit  6

全局安装TS

npm install -g typescript

在项目根目录添加 tsconfig.json

{
    \"compilerOptions\": {
        \"strictNullChecks\": true,
        \"moduleResolution\": \"node\",
        \"allowSyntheticDefaultImports\": true,
        \"experimentalDecorators\": true,
        \"jsx\": \"preserve\",
        \"noUnusedParameters\": true,
        \"noUnusedLocals\": true,
        \"target\": \"es6\",
        \"lib\": [
            \"dom\",
            \"es7\"
        ]
    },
    \"exclude\": [
        \"node_modules\",
        \"lib\",
        \"es\"
    ]
}
2018-10-18 09:26:45   Visit  8
        -webkit-filter: grayscale(100%); 
        -moz-filter: grayscale(100%); 
        -ms-filter: grayscale(100%); 
        -o-filter: grayscale(100%); 
        filter:progid:DXImageTransform.Microsoft.BasicImage(grayscale=1);  
        _filter:none; 
2018-10-18 09:25:35   Visit  7
    -webkit-filter: invert(100%); 
    filter: invert(100%);
2018-10-17 10:34:42   Visit  5
import {
  Router, 
  Link 
} from \'react-router-dom\' 
import { Layout, Menu,   Icon } from \'antd\';

import Routers from \"./routers/routers\" 
import createBrowserHistory from \'history/createBrowserHistory\' 
const history = createBrowserHistory()
render() { 
    const pathName = history.location.pathname;

    return <Router history={history}  ><Layout className=\"PageAPP\">
      <Header className=\"header\">
        <div className=\"logo\" />
        <Menu
          theme=\"dark\"
          mode=\"horizontal\"
          defaultSelectedKeys={[pathName]} 
          style={{ lineHeight: \'64px\' }}
        >
          {
            menuData.map(function (item) {
              return <Menu.Item key={item.url} 
              item={item}  >
              <Link to={item.url} >{item.title}</Link >  
              </Menu.Item>
            })
          }
        </Menu>
      </Header>
      <Layout>
  
        <Layout style={{ padding: \'0 24px 24px\' }}> 
          <Content style={{ background: \'#fff\', padding: 24, margin: 0, minHeight: 280, display:\'flex\' }}>
              <Route exact path=\"/\" component={Home} />
              <Route path=\"/user\" component={User} />
              <Route path=\"/about\" component={About} /> */}
         
          </Content>
        </Layout>
      </Layout>
    </Layout>
    </Router>
  }
2018-10-16 17:04:12   Visit  14
> console.log(...[1,2,3])
< 1 2 3 
> console.log(...[1,2,[4,5],3])
< 1 2 (2)?[4, 5] 3
> function a(e,...args){console.log(e,args)}
> a(1,2,4,5)
< 1 (3)?[2, 4, 5]
> function f(x,y,z){console.log(x,y,z)}
> f(...[1,2,3])
< 1 2 3
2018-10-15 17:33:02   Visit  15

在IIS中设置HTTP响应标头

Access-Control-Allow-Headers:x-requested-with
access-control-allow-methods:HEAD, GET
Access-Control-Allow-Origin:*
access-control-max-age:3000

重启iis应用,清空浏览器缓存,再次访问,已经可以跨域访问了

2018-10-15 10:26:38   Visit  38

combineReducers 主要用来合并零碎的reducer

定义reducer

const initialState = {
    text: \\\"Map 1\\\"
};

/*
   对应不同 action.type 的处理函数,需要返回一个新的 state
   也可以 switch 语句 处理不同 action.type
*/
const typesCommands = {
    [\\\"CHANGE_TEXT\\\"](state, action) {
        console.log(action)
        var v = Object.assign({}, state, {
            text: action.text
        });
        console.log(v);
        return v;
    } 
} 
export default function reducer(state = initialState, action) { 
    const actionResponse = typesCommands[action.type]; 
    let v = actionResponse ? actionResponse(state, action) : state ;
    return v;
}

使用combineReducers

import { combineReducers } from \\\'redux\\\';
import { routerReducer } from \\\'react-router-redux\\\';
 import mapreducer from \\\'./map\\\'


const Reducers = {
    mapreducer
} 
export default combineReducers(Reducers); 

组件代码改动

import React from \"react\";
import { connect } from \'react-redux\';  
class Map extends React.Component {
    render() {
        const { handleChange } = this.props;
        return (
            <div className=\"fullContent\" style={{ backgroundColor: \"red\" }}>
                Type something:
                <input onChange={handleChange}
                    value={this.props.text} />{this.props.text}
            </div>
        );
    }
}

 

const handleChangeAction = {
    type: \'CHANGE_TEXT\'
}
const MapAction = { type: \'mapinput\' }
export default connect(
    state => ({ text: state.mapreducer.text }),
    dispatch => ({
        handleChange: (e, a, b) => {
            let text = e.target.value;
            dispatch({
                type: \'CHANGE_TEXT\', text: text
            })
        },
    })
)(Map);

属性存储在state.mapreducer中

2018-10-12 11:55:14   Visit  15

求数组中的最大值

> let arr = [1,2,3,5,3,2];
> Math.max.apply(Math, arr);
< 5