Giter Site home page Giter Site logo

请指点,万分感激 about react-luo HOT 10 CLOSED

javaluo avatar javaluo commented on May 28, 2024
请指点,万分感激

from react-luo.

Comments (10)

javaLuo avatar javaLuo commented on May 28, 2024

需要npm install --save-dev babel-preset-stage-1
然后将根目录下的.babelrc中的"stage-3" 修改为 “stage-1” 就可以使用修饰器了

from react-luo.

wangjunwei910208 avatar wangjunwei910208 commented on May 28, 2024

@javaLuo 这个需要我自己配置吗? 还是说您已经配置好了 ,我可以直接用?

from react-luo.

wangjunwei910208 avatar wangjunwei910208 commented on May 28, 2024

@javaLuo 根据您的提示,修改后,这样编辑,如下:
@connect(
state => ({
num: state.app.num,
}),
dispatch =>({
})
)
class Mytest extends React.Component {
constructor(props) {
super(props);
this.state = {
};
}
render() {
const {num} = this.props;
console.log(num);
return (


)
}
}
运行项目时提示我识别不了@

from react-luo.

javaLuo avatar javaLuo commented on May 28, 2024

重新npm run dll 试试

from react-luo.

wangjunwei910208 avatar wangjunwei910208 commented on May 28, 2024

@javaLuo 还是 报这个错
ERROR in ./src/a_container/test/index.js

C:\Users\Administrator\Desktop\react_luo\src\a_container\test\index.js
142:1 error Parsing error: Unexpected character '@'

✖ 1 problem (1 error, 0 warnings)

from react-luo.

javaLuo avatar javaLuo commented on May 28, 2024

额...不是吧,我这边测试可以识别@了

from react-luo.

wangjunwei910208 avatar wangjunwei910208 commented on May 28, 2024

@javaLuo 我从新拷贝你的项目 然后按您的指示,报如下错误:
ERROR in ./src/a_container/test/index.js

C:\Users\Administrator\Desktop\react+redux\react_luo\src\a_container\test\index. js
143:1 error Parsing error: Unexpected character '@'

1 problem (1 error, 0 warnings)

@ ./src/route/index.js 25:14-50
@ ./src/app.js
@ multi webpack-dev-server/client?http://localhost:8888 webpack/hot/dev-server ./src/app

ERROR in ./src/a_container/test/index.js
Module build failed: SyntaxError: C:/Users/Administrator/Desktop/react+redux/rea ct_luo/src/a_container/test/index.js: Decorators are not officially supported ye t in 6.x pending a proposal update.
However, if you need to use them you can install the legacy decorators transform with:

npm install babel-plugin-transform-decorators-legacy --save-dev

and add the following line to your .babelrc file:

{
"plugins": ["transform-decorators-legacy"]
}

The repo url is: https://github.com/loganfsmyth/babel-plugin-transform-decorator s-legacy.

148 | })
149 | )

150 | class Mytest extends React.Component {
| ^
151 | constructor(props) {
152 | super(props);
153 | this.state = {

@ ./src/route/index.js 25:14-50
@ ./src/app.js
@ multi webpack-dev-server/client?http://localhost:8888 webpack/hot/dev-server ./src/app
然后我这样:
npm install babel-plugin-transform-decorators-legacy --save-dev

接着修改.babelrc
{
"presets": ["es2015", "stage-1", "react"],
"plugins": [
"transform-decorators-legacy",
["import", {
"libraryName": "antd",
"style": "css"
}
]
]
}
最后运行时还是报错
C:\Users\Administrator\Desktop\react+redux\react_luo\src\a_container\test\index.js
143:1 error Parsing error: Unexpected character '@'

✖ 1 problem (1 error, 0 warnings)

@ ./src/route/index.js 25:14-50
@ ./src/app.js
@ multi webpack-dev-server/client?http://localhost:8888 webpack/hot/dev-server ./src/app

from react-luo.

javaLuo avatar javaLuo commented on May 28, 2024

我更新了代码,重新上传了。你再试试。
暂时取消了eslint代码检测。eslint现在的版本不支持decorator

from react-luo.

wangjunwei910208 avatar wangjunwei910208 commented on May 28, 2024

@javaLuo 您好,现在能识别@了,但是运行后会报这个错,如下:
vendor.dll.js:34 Uncaught TypeError: Cannot read property 'location' of undefined
at new t (vendor.dll.js:34)
at d._constructComponentWithoutOwner (vendor.dll.js:43)
at d._constructComponent (vendor.dll.js:43)
at d.mountComponent (vendor.dll.js:43)
at Object.mountComponent (vendor.dll.js:20)
at d.performInitialMount (vendor.dll.js:43)
at d.mountComponent (vendor.dll.js:43)
at Object.mountComponent (vendor.dll.js:20)
at d.performInitialMount (vendor.dll.js:43)
at d.mountComponent (vendor.dll.js:43)
再次麻烦您给指导下了

from react-luo.

javaLuo avatar javaLuo commented on May 28, 2024

重新拉一下代码
重新install
那是react-router版本不兼容
暂时没有升级到react-router4.0

from react-luo.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.