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

编译h5后再编译 weapp 编译失败 isCallExpression #980

Closed
QTTQ opened this issue Nov 1, 2018 · 7 comments
Closed

编译h5后再编译 weapp 编译失败 isCallExpression #980

QTTQ opened this issue Nov 1, 2018 · 7 comments

Comments

@QTTQ
Copy link

QTTQ commented Nov 1, 2018

如果是提交 bug,请搜索文档和 issue,确认以下事项:

  • 该问题没有在其他 issue 和文档讨论到,不属于重复内容

  • 分割线以下的模板除了「 补充信息」每一样都必填

如果不满足以上两点要求的 bug 报告,issue 会被直接关掉。

请多多理解,您现在的不便将会使 Taro 开发者更高效地定位你的问题,修复你的问题。像你一样的 Taro 的使用者也可以通过搜索找到你提供的 bug,对各方都有很大好处。

🙏🙏🙏
阅读完后请在提交的issue中删除以上内容,包括分割线。

问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]

复现步骤
[复现问题的步骤]

  1. Go to '...'
  2. Click on '....'
  3. Scroll down to '....'
  4. See error

[或者可以直接贴源代码,能贴文字就不要截图]

// 这里可以贴代码

image

期望行为
[这里请用简洁清晰的语言描述你期望的行为]

报错信息

[这里请贴上你的完整报错截图或文字]

系统信息

  • 操作系统: [e.g. Windows 10]
  • Taro 版本 [e.g. v.0.0.64]
  • Node.js 版本 [e.g. v9.0.0]
  • 报错平台 [h5, weapp]

补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@luckyadam
Copy link
Member

把页面代码贴一下

@QTTQ
Copy link
Author

QTTQ commented Nov 1, 2018

`import Taro, { Component } from '@tarojs/taro'
import { View, ScrollView } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import { AtSegmentedControl, AtCard } from 'taro-ui'
// import { add, minus, asyncAdd, asyncAddText } from '../../actions/counter'
import { loading, asyncRequset } from '../../actions/common'
import './index.scss'
// import searchPng from '../../asset/images/search.png'
// import lightingPng from '../../asset/images/lighting.png'
// import icon9 from '../../asset/images/icon9.jpeg'

class MyIndex extends Component {
config = {
navigationBarTitleText: '首页'
}
constructor() {
super(...arguments)
this.dataArr = []
this.did = false
this.state = {
height: 0,
current: 0,
pages: 1,
dataArr: []
}
}
componentWillReceiveProps(nextProps) {
}
updateList = async () => {
this.tokenSign = true
if (this.props.common.loading) return
this.setState({
pages: 1
}, () => {
this.requestUrl(this.state.current)
})
}

requestUrl = (n, text = "刷新中。。。") => {
let url = "AllArticle"
this.tokenSign = true
if (this.props.common.loading) return
let data = { page: this.state.pages }
if (!this.props.common.userData.token && n == 2) {
Taro.showToast({ title: "请先登录", icon: 'none', duration: 2000 })
this.tokenSign = false
return
}
let token = this.props.common.userData.token
if (n == 1) {
data = { page: this.state.pages }
url = "GetMostThunmbArticle"
} else if (n == 2) {
data = { token, page: this.state.pages }
url = "jwt/MyArticle"
}
this.props.asyncRequset(text, data, url)
}
getMoreList = async (e) => {
if (this.props.common.loading) return
this.setState({
pages: this.state.pages + e
}, () => {
this.requestUrl(this.state.current, "加载更多。。。")
})
}
handleClick(value) {
this.setState({
current: value,
pages: 1
}, () => {
this.did = false
this.dataArr = []
this.requestUrl(value)
})
}
componentDidMount() {
let self = this
Taro.getSystemInfo({
success(res) {
self.setState({
height: res.windowHeight - 46
})
}
})
this.updateList()
}

render() {
const { height } = this.state
const { listData } = this.props.homePage
const { loading } = this.props.common
const retViewFn = (loading, listData) => {
this.dataArr = [...this.dataArr, ...listData]
this.did = true
return !loading ? this.tokenSign || this.state.current == 0 ?
this.dataArr.map((v, i) => {
return <AtCard
note={v.thunmbs}
extra={new Date(v.ctTime).getFullYear()}
title={v.name}
thumb={v.actor}
>
{v.context}

}) : null : 暂无信息。。。。。
}
return (

<AtSegmentedControl
values={['世界愿望', '点赞最多的愿望', '我的愿望']}
onClick={this.handleClick.bind(this)}
current={this.state.current}
/>

<ScrollView className='container'
scrollY
scrollWithAnimation
scrollTop='0'
// lowerThreshold={20}
lowerThreshold="10"
upperThreshold="10"
// style='height:100%;position: absolute;top: 44px;background: rgb(242, 226, 230);'
style={{ 'height': height - 46 + "px", 'background': 'rgb(242, 226, 230)' }}
onScrollToUpper={this.updateList}
onScrollToLower={this.getMoreList.bind(this, 1)}
>
{
this.state.current === 0
? retViewFn(loading, listData) : null
}
{
this.state.current === 1
? retViewFn(loading, listData) : null
}
{
this.state.current === 2
? retViewFn(loading, listData) : null
}



)
}
}

export default connect(({ counter, homePage, common }) => ({
counter, homePage, common
}), (dispatch) => ({
asyncRequset(text, data, url) {
dispatch(asyncRequset(text, data, url))
},
loading() {
dispatch(loading())
}
}))(MyIndex)`

@luckyadam
Copy link
Member

你的代码本身就是有问题的,麻烦贴一下正常的代码

@QTTQ
Copy link
Author

QTTQ commented Nov 1, 2018

import { View, ScrollView } from '@tarojs/components'
import { connect } from '@tarojs/redux'
import { AtSegmentedControl, AtCard } from 'taro-ui'
// import { add, minus, asyncAdd, asyncAddText } from '../../actions/counter'
import { loading, asyncRequset } from '../../actions/common'
import './index.scss'
// import searchPng from '../../asset/images/search.png'
// import lightingPng from '../../asset/images/lighting.png'
// import icon9 from '../../asset/images/icon9.jpeg'

class MyIndex extends Component {
  config = {
    navigationBarTitleText: '首页'
  }
  constructor() {
    super(...arguments)
    this.dataArr = []
    this.did = false
    this.state = {
      height: 0,
      current: 0,
      pages: 1,
      dataArr: []
    }
  }
  componentWillReceiveProps(nextProps) {
  }
  updateList = async () => {
    this.tokenSign = true
    if (this.props.common.loading) return
    this.setState({
      pages: 1
    }, () => {
      this.requestUrl(this.state.current)
    })
  }

  requestUrl = (n, text = "刷新中。。。") => {
    let url = "AllArticle"
    this.tokenSign = true
    if (this.props.common.loading) return
    let data = { page: this.state.pages }
    if (!this.props.common.userData.token && n == 2) {
      Taro.showToast({ title: "请先登录", icon: 'none', duration: 2000 })
      this.tokenSign = false
      return
    }
    let token = this.props.common.userData.token
    if (n == 1) {
      data = { page: this.state.pages }
      url = "GetMostThunmbArticle"
    } else if (n == 2) {
      data = { token, page: this.state.pages }
      url = "jwt/MyArticle"
    }
    this.props.asyncRequset(text, data, url)
  }
  getMoreList = async (e) => {
    console.log("---------getMoreList--------------")
    if (this.props.common.loading) return
    this.setState({
      pages: this.state.pages + e
    }, () => {
      this.requestUrl(this.state.current, "加载更多。。。")
    })
  }
  handleClick(value) {
    console.log("---------handleClick--------------")
    this.setState({
      current: value,
      pages: 1
    }, () => {
      this.did = false
      this.dataArr = []
      this.requestUrl(value)
    })
  }
  componentDidMount() {
    let self = this
    Taro.getSystemInfo({
      success(res) {
        self.setState({
          height: res.windowHeight - 46
        })
      }
    })
    this.updateList()
  }

  render() {
    const { height } = this.state
    const { listData } = this.props.homePage
    const { loading } = this.props.common
    const retViewFn = (loading, listData) => {
      this.dataArr = [...this.dataArr, ...listData]
      this.did = true
      console.log("------------render------------------");
      return !loading ? this.tokenSign || this.state.current == 0 ?
        this.dataArr.map((v, i) => {
          return <AtCard
            note={v.thunmbs}
            extra={new Date(v.ctTime).getFullYear()}
            title={v.name}
            thumb={v.actor}
          >
            {v.context}
          </AtCard>
        }) : null : <View>暂无信息。。。。。</View>
    }
    return (
      <View className="myIndex">
        <AtSegmentedControl
          values={['世界愿望', '点赞最多的愿望', '我的愿望']}
          onClick={this.handleClick.bind(this)}
          current={this.state.current}
        />
        <View className='tab-content'>
          <ScrollView className='container'
            scrollY
            scrollWithAnimation
            scrollTop='0'
            lowerThreshold="10"
            upperThreshold="10"
            // style='height:100%;position: absolute;top: 44px;background: rgb(242, 226, 230);'
            style={{ 'height': height + "px", 'background': 'rgb(242, 226, 230)' }}
            onScrollToUpper={this.updateList}
            onScrollToLower={this.getMoreList.bind(this, 1)}
          >
           {
                 retViewFn(loading, listData)
            }
          </ScrollView>
        </View>
      </View>
    )
  }
}

export default connect(({ counter, homePage, common }) => ({
  counter, homePage, common
}), (dispatch) => ({
  asyncRequset(text, data, url) {
    dispatch(asyncRequset(text, data, url))
  },
  loading() {
    dispatch(loading())
  }
}))(MyIndex)

@luckyadam
Copy link
Member

不要在 render 里面定义函数返回 jsx ,目前还不支持

@QTTQ
Copy link
Author

QTTQ commented Nov 2, 2018

好的 收到 谢谢

@luckyadam
Copy link
Member

Duplicate of #848

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

2 participants