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

编译小程序 import json出错 TypeError: Property properties[0] of ObjectExpression expected node to be of a type ["ObjectMethod","ObjectProperty","SpreadProperty"] but instead got "ObjectExpression" #547

Closed
jy1989 opened this issue Aug 29, 2018 · 3 comments

Comments

@jy1989
Copy link

jy1989 commented Aug 29, 2018

编译小程序 import json出错

编译 页面文件 src/pages/index/index
TypeError: Property properties[0] of ObjectExpression expected node to be of a type ["ObjectMethod","ObjectProperty","SpreadProperty"] but instead got "ObjectExpression"
at validate (E:\pet\cat-wiki\node_modules.6.26.0@babel-types\lib\definitions\index.js:109:13)
at validator (E:\pet\cat-wiki\node_modules.6.26.0@babel-types\lib\definitions\index.js:57:7)
at Object.validate (E:\pet\cat-wiki\node_modules.6.26.0@babel-types\lib\definitions\index.js:190:10)
at validate (E:\pet\cat-wiki\node_modules.6.26.0@babel-types\lib\index.js:505:9)
at Object.builder (E:\pet\cat-wiki\node_modules.6.26.0@babel-types\lib\index.js:466:7)
at ImportDeclaration (E:\pet\cat-wiki\node_modules.1.0.0-beta.19@@tarojs\cli\src\weapp.js:499:130)
at NodePath._call (E:\pet\cat-wiki\node_modules.6.26.0@babel-traverse\lib\path\context.js:76:18)
at NodePath.call (E:\pet\cat-wiki\node_modules.6.26.0@babel-traverse\lib\path\context.js:48:17)
at NodePath.visit (E:\pet\cat-wiki\node_modules.6.26.0@babel-traverse\lib\path\context.js:105:12)
at TraversalContext.visitQueue (E:\pet\cat-wiki\node_modules.6.26.0@babel-traverse\lib\context.js:150:16)

定位到是import json的问题:


import Taro, { Component } from '@tarojs/taro'
import { View, Text } from '@tarojs/components'
import './index.css'
import data from '../data.json'
export default class Index extends Component {

  config = {
    navigationBarTitleText: '首页'
  }

  componentWillMount () { }

  componentDidMount () {
    console.log(data)
  }

  componentWillUnmount () { }

  componentDidShow () { }

  componentDidHide () { }

  render () {
    const pets = data.map((pet) => {
      return <View key={pet.id} className='item'>
              <Text>{pet.name}</Text>
             </View>
    });


    return (
      <View className='index'>
        {pets}
      </View>
    )
  }
}

json是一个array

image

报错信息

image

系统信息

  • 操作系统:Windows 10
  • Taro 版本 1.0.0-beta.18
  • Node.js 版本v8.11.4

h5编译正常
image

@luckyadam
Copy link
Member

luckyadam commented Aug 30, 2018

json 文件能不能提供一部分,数组的话,提供一两项就好

@jy1989
Copy link
Author

jy1989 commented Aug 30, 2018

@luckyadam 你好 是这样的
format.1535606951046.json.zip

@luckyadam
Copy link
Member

已修复,下个版本发布~

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