问答详情
源自:1-2 搭建Taro环境

You may need an appropriate loader to handle this file type.

npm run dev:h5 命令报错了; 

You may need an appropriate loader to handle this file type. 

不知什么情况?是不是什么配置不对,还是安装出错了。

提问者:慕莱坞2001706 2019-03-17 03:29

个回答

  • 稻鹰
    2019-03-18 11:30:54

    H5 模式下编译报错?

    如果出现类似 You may need an appropriate loader to handle this file type 的问题,如下:

    ./node_modules/_taro-ui@1.5.4@taro-ui/dist/h5/components/pagination/index.js 101
    :11
    Module parse failed: Unexpected token (101:11)
    You may need an appropriate loader to handle this file type.
    |     };
    |
    >     return <View className={classNames(rootClassName, classObject, this.props.
    className)} style={customStyle}>
    |         <View className="at-pagination__operate">
    |           <View className="at-pagination__btns">

    请在 config/index.js 文件中添加如下配置项:

    h5: {
     esnextModules: ['taro-ui']
    }

    另外:

    // app.js
    import 'taro-ui/dist/style/index.scss' // 全局引入一次即可

    希望能帮到你!