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

Taro v1.3.11 Property value expected type of string but got null #4013

Closed
zhangchenna opened this issue Jul 30, 2019 · 11 comments
Closed

Taro v1.3.11 Property value expected type of string but got null #4013

zhangchenna opened this issue Jul 30, 2019 · 11 comments
Assignees

Comments

@zhangchenna
Copy link

zhangchenna commented Jul 30, 2019

👽 Taro v1.3.11
Property value expected type of string but got null

TypeError: Property value expected type of string but got null
    at Object.validate (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/definitions/index.js:161:13)
    at validate (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/index.js:505:9)
    at Object.builder (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-types/lib/index.js:466:7)
    at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/render.js:1287:77
    at Array.map (<anonymous>)
    at RenderParser.handleConditionExpr (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/render.js:1285:58)
    at /usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/render.js:148:30
    at RenderParser.handleJSXElement (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/render.js:95:17)
    at enter (/usr/local/lib/node_modules/@tarojs/cli/node_modules/@tarojs/transformer-wx/lib/src/render.js:147:26)
    at NodePath._call (/usr/local/lib/node_modules/@tarojs/cli/node_modules/babel-traverse/lib/path/context.js:76:18)
Taro CLI 1.3.11 environment info:
    System:
      OS: macOS 10.14.5
      Shell: 3.2.57 - /bin/bash
    Binaries:
      Node: 12.6.0 - /usr/local/bin/node
      Yarn: 1.17.3 - /usr/local/bin/yarn
      npm: 6.9.0 - /usr/local/bin/npm
    npmPackages:
      @tarojs/async-await: 1.3.11 => 1.3.11 
      @tarojs/components: 1.3.11 => 1.3.11 
      @tarojs/mobx: 1.3.11 => 1.3.11 
      @tarojs/plugin-babel: 1.3.11 => 1.3.11 
      @tarojs/plugin-csso: 1.3.11 => 1.3.11 
      @tarojs/plugin-sass: 1.3.11 => 1.3.11 
      @tarojs/plugin-uglifyjs: 1.3.11 => 1.3.11 
      @tarojs/router: 1.3.11 => 1.3.11 
      @tarojs/taro: 1.3.11 => 1.3.11 
      @tarojs/taro-weapp: 1.3.11 => 1.3.11 
      @tarojs/webpack-runner: 1.3.11 => 1.3.11 
      eslint-config-taro: 1.3.11 => 1.3.11 
      eslint-plugin-taro: 1.3.11 => 1.3.11 
      nerv-devtools: 1.4.3 => 1.4.3 
      nervjs: 1.4.3 => 1.4.3 

1.3.10 正常

@taro-bot
Copy link

taro-bot bot commented Jul 30, 2019

欢迎提交 Issue~

如果你提交的是 bug 报告,请务必遵循 Issue 模板的规范,尽量用简洁的语言描述你的问题,最好能提供一个稳定简单的复现。🙏🙏🙏

如果你的信息提供过于模糊或不足,或者已经其他 issue 已经存在相关内容,你的 issue 有可能会被关闭。

Good luck and happy coding~

@yuche
Copy link
Contributor

yuche commented Jul 30, 2019

复现代码

@zhangchenna
Copy link
Author

zhangchenna commented Jul 30, 2019

import Taro, { Component } from '@tarojs/taro';
import { View } from '@tarojs/components';
import { AtTabBar } from 'taro-ui';
import Home from '../home/index';
import Shop from '../shop/index';
import Publisher from '../publisher/index';
import Mine from '../mine/index';
import './index.scss';

export default class Index extends Component {
    config = {
        onReachBottomDistance: 100
    };

    constructor(props) {
        super(props);
        this.state = {
            current: 0,
            navTitle: '剧本杀',
            reachBottom: false,
            indexData: this.$router.params
        };
    }

    onReachBottom() {
        this.setState({
            reachBottom: true
        });
    }

    componentDidMount() {
        let { indexData } = this.state;
        if (!Object.keys(indexData).length == 0) {
            this.switchTab(indexData.num);
        }
        Taro.setNavigationBarTitle({
            title: this.state.navTitle
        });
    }

    switchTab(num) {
        let title = {
            0: '剧本杀',
            1: '店家总列表',
            2: '工作室列表',
            3: '我的'
        };
        num = Number(num);
        this.setState(
            {
                current: num,
                navTitle: title[num]
            },
            () => {
                Taro.setNavigationBarTitle({
                    title: this.state.navTitle
                });
            }
        );
    }

    renderContent() {
        const { current, reachBottom } = this.state;
        return {
            0: <Home reachBottom={reachBottom} />,
            1: <Shop />,
            2: <Publisher />,
            3: <Mine />
        }[current];
    }

    render() {
        return (
            <View>
                {this.renderContent()}
                <View className="index-placeholder" />
                <AtTabBar
                    fixed
                    fontSize="10"
                    color="#333"
                    selectedColor="#ee4b00"
                    tabList={[
                        { title: '首页', iconType: 'home' },
                        { title: '店家', iconType: 'money' },
                        { title: '工作室', iconType: 'shopping-bag-2' },
                        { title: '我的', iconType: 'bullet-list' }
                    ]}
                    onClick={this.switchTab.bind(this)}
                    current={this.state.current}
                />
            </View>
        );
    }
}

锁定报错位置

renderContent() {
        const { current, reachBottom } = this.state;
        return {
            0: <Home reachBottom={reachBottom} />,
            1: <Shop />,
            2: <Publisher />,
            3: <Mine />
        }[current];
    }

1.3.11cli 这里报错 Property value expected type of string but got null

@zhangchenna zhangchenna changed the title Property value expected type of string but got null Taro v1.3.11 Property value expected type of string but got null Jul 30, 2019
@zhangchenna
Copy link
Author

@yuche taro-cli v1.3.11 的问题

@yuche
Copy link
Contributor

yuche commented Jul 30, 2019

        return {
            0: <Home reachBottom={reachBottom} />,
            1: <Shop />,
            2: <Publisher />,
            3: <Mine />
        }[current];

0,1,2,3 用引号包起来试试

@taro-bot
Copy link

taro-bot bot commented Jul 30, 2019

CC @yuche

@zhangchenna
Copy link
Author

 let title = {
            '0': '剧本杀',
            '1': '店家总列表',
            '2': '工作室列表',
            '3': '我的'
        };

依然提示 Property value expected type of string but got null

@zhangchenna
Copy link
Author

v1.3.11 cli 新版本jsx 枚举 有问题

@zhangchenna
Copy link
Author

@yuche

@yuche
Copy link
Contributor

yuche commented Jul 31, 2019

    renderContent() {
        const { current, reachBottom } = this.state;
        return {
            '0': <Home reachBottom={reachBottom} />,
            '1': <Shop />,
            '2': <Publisher />,
            '3': <Mine />
        }[current];
    }

就这样写

@zhangchenna
Copy link
Author

    renderContent() {
        const { current, reachBottom } = this.state;
        return {
            '0': <Home reachBottom={reachBottom} />,
            '1': <Shop />,
            '2': <Publisher />,
            '3': <Mine />
        }[current];
    }

就这样写

可以了。。。

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