我有一个组件:
import React from 'react';
export default class LeftNavigation extends React.Component {
static contextTypes = {
getStore: React.PropTypes.func.isRequired
};
render() {
return (
<div>
Left
</div>
)
}
}
但是当我尝试捆绑(使用JSPM)时,我得到:
SyntaxError: file:///C:/wamp/www/rentapp/public/src/components/add-property/LeftNavigation.js: Unexpected token (5:24)
export default class LeftNavigation extends React.Component {
static contextTypes = {
getStore: React.PropTypes.func.isRequired
}
};
我该如何解决这个问题?
这是我的package.json
文件:
{
"private": true,
"scripts": {
"prod": "gulp --production",
"dev": "gulp watch"
},
"devDependencies": {
"bootstrap-sass": "^3.0.0",
"gulp": "^3.9.1",
"jspm": "^0.16.34",
"laravel-elixir": "^5.0.0"
},
"jspm": {
"directories": {
"baseURL": "public"
},
"dependencies": {
"body-parser": "npm:body-parser@^1.15.0",
"express": "npm:express@^4.13.4",
"fluxible": "npm:fluxible@^1.1.0",
"fluxible-addons-react": "npm:fluxible-addons-react@^0.2.8",
"jsx": "github:floatdrop/plugin-jsx@^1.2.1",
"react": "npm:react@^15.0.2",
"react-dom": "npm:react-dom@^15.0.2",
"react-router": "npm:react-router@^2.4.0"
},
"devDependencies": {
"babel": "npm:babel-core@^6.8.0",
"babel-runtime": "npm:babel-runtime@^5.8.24",
"core-js": "npm:core-js@^1.1.4"
}
},
"dependencies": {
"babel": "^6.5.2",
"body-parser": "^1.15.0",
"express": "^4.13.4",
"fluxible": "^1.1.0",
"react": "^15.0.2"
},
"name": "rentapp",
"description": "[![Build Status](https://travis-ci.org/laravel/framework.svg)](https://travis-ci.org/laravel/framework) [![Total Downloads](https://poser.pugx.org/laravel/framework/d/total.svg)](https://packagist.org/packages/laravel/framework) [![Latest Stable Version](https://poser.pugx.org/laravel/framework/v/stable.svg)](https://packagist.org/packages/laravel/framework) [![Latest Unstable Version](https://poser.pugx.org/laravel/framework/v/unstable.svg)](https://packagist.org/packages/laravel/framework) [![License](https://poser.pugx.org/laravel/framework/license.svg)](https://packagist.org/packages/laravel/framework)",
"version": "1.0.0",
"main": "gulpfile.js",
"directories": {
"test": "tests"
},
"keywords": [],
"author": "",
"license": "ISC",
}
答案 0 :(得分:0)
答案 1 :(得分:0)
将config.js的第一位更改为以下内容解决了问题,请不要知道原因:
System.config({
baseURL: "/",
defaultJSExtensions: true,
transpiler: "babel",
babelOptions: {
"optional": [
"runtime",
"optimisation.modules.system"
],
"blacklist": [],
"stage": 0
},
...