Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

你好,@observable 的时候报错了,是什么原因呢? #1

Open
pskeeter opened this issue Jun 13, 2017 · 3 comments
Open

你好,@observable 的时候报错了,是什么原因呢? #1

pskeeter opened this issue Jun 13, 2017 · 3 comments

Comments

@pskeeter
Copy link

import { observable, computed, autorun, action } from 'mobx'

class HostUser {
  @observable defaultVal = 'abc'
}

export default new HostUser()

import React from 'react'
import Nav from './Nav'

import {observer} from 'mobx-react'
import HostUser from '../model/index'


@observer
export default class Users extends React.Component {

  constructor(props){
    super(props)
    console.log(props)
    this.state = {
      a:'个人'
    }
  }

  render() {
    console.log(this)
    return (
      <div className='page page-current'>

        <header className='bar bar-nav'>
          <h1 className='title'>{this.state.a}</h1>
        </header>

        <Nav item={ 2 }/>

        <div className='content'>
          <h1 style={{ textAlign: 'center' }}>个人</h1>
        </div>
      </div>
    )
  }
}

BabelLoaderError: SyntaxError: C:/Users/Administrator/Desktop/ReactMobx/app/module/model/index.js: Unexpected token (4:25)

  2 | 
  3 | class HostUser {
> 4 |   @observable defaultVal = 'abc'
    |                          ^
  5 | }
  6 | 
  7 | export default new HostUser()
@lanistor
Copy link
Owner

是否安装了babel-plugin-transform-decorators-legacy?

@pskeeter
Copy link
Author

这个依赖安装了,有没有可能是其他的问题呢?

@guanbiao33
Copy link

和楼主一样的问题,
@observable state = {
number:0
}
等号那里报错。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants