NervJS / taro-ui

一款基于 Taro 框架开发的多端 UI 组件库
https://taro-ui.taro.zone
MIT License
4.52k stars 756 forks source link

在 taro-next 中,无法正常使用taro-ui。 #1107

Open vincentCheng opened 4 years ago

vincentCheng commented 4 years ago

问题描述 在 taro-next 中,无法正常使用taro-ui。

复现步骤

我的安装步骤是这样的: 1、yarn global add @tarojs/cli@next 2、taro init 项目名字。等等常规的步骤 3、在项目中安装 taro-ui, yarn add taro-ui 4、在模板创建的文件 “src\pages\index\index.tsx” 中写入以下代码

import React, { Component } from "react";
import { View, Text } from "@tarojs/components";
import { AtDrawer } from "taro-ui";
import "./index.scss";

export default class Index extends Component {
  componentWillMount() {}

  componentDidMount() {}

  componentWillUnmount() {}

  componentDidShow() {}

  componentDidHide() {}

  render() {
    return (
      <View className="index">
        <Text>Hello world!</Text>
        <AtDrawer show={true} mask>
          <View className="drawer-item">优先展示items里的数据</View>
          <View className="drawer-item">如果items没有数据就会展示children</View>
          <View className="drawer-item">
            这是自定义内容 <AtIcon value="home" size="20" />
          </View>
          <View className="drawer-item">这是自定义内容</View>
        </AtDrawer>
      </View>
    );
  }
}

5、添加h5的设置: 在 “config\index.js” 中的h5里添加“esnextModules: ["taro-ui"]”

6、运行项目: yarn dev:h5

期望行为 我当然期望能够得到正常的画面

报错信息 🙅 Failed to compile.

./node_modules/taro-ui/dist/h5/components/accordion/index.js Module not found: Can't resolve 'nervjs' in 'D:\yczs\test_drawer\node_modules\taro-ui\dist\h5\components\accordion'

系统信息

👽 Taro v3.0.0-rc.6

Taro CLI 3.0.0-rc.6 environment info: System: OS: Windows 10 Binaries: Node: 12.16.1 - C:\Program Files\nodejs\node.EXE Yarn: 1.22.4 - ~\AppData\Roaming\npm\yarn.CMD npm: 6.13.4 - C:\Program Files\nodejs\npm.CMD

补充信息 1、我真的不知道问题出在哪里...这个nervjs是什么鬼,是不是脚手架安装的时候没有装上去? 2、这是我的package.json信息

{
  "name": "test_drawer",
  "version": "1.0.0",
  "private": true,
  "description": "",
  "templateInfo": {
    "name": "default",
    "typescript": true,
    "css": "sass"
  },
  "scripts": {
    "build:weapp": "taro build --type weapp",
    "build:swan": "taro build --type swan",
    "build:alipay": "taro build --type alipay",
    "build:tt": "taro build --type tt",
    "build:h5": "taro build --type h5",
    "build:rn": "taro build --type rn",
    "build:qq": "taro build --type qq",
    "build:quickapp": "taro build --type quickapp",
    "dev:weapp": "npm run build:weapp -- --watch",
    "dev:swan": "npm run build:swan -- --watch",
    "dev:alipay": "npm run build:alipay -- --watch",
    "dev:tt": "npm run build:tt -- --watch",
    "dev:h5": "npm run build:h5 -- --watch",
    "dev:rn": "npm run build:rn -- --watch",
    "dev:qq": "npm run build:qq -- --watch",
    "dev:quickapp": "npm run build:quickapp -- --watch"
  },
  "browserslist": [
    "last 3 versions",
    "Android >= 4.1",
    "ios >= 8"
  ],
  "author": "",
  "dependencies": {
    "@babel/runtime": "^7.7.7",
    "@tarojs/components": "3.0.0-rc.6",
    "@tarojs/react": "3.0.0-rc.6",
    "@tarojs/runtime": "3.0.0-rc.6",
    "@tarojs/taro": "3.0.0-rc.6",
    "react": "^16.10.0",
    "react-dom": "^16.10.0",
    "taro-ui": "^2.3.4"
  },
  "devDependencies": {
    "@babel/core": "^7.8.0",
    "@tarojs/mini-runner": "3.0.0-rc.6",
    "@tarojs/webpack-runner": "3.0.0-rc.6",
    "@types/react": "^16.0.0",
    "@types/webpack-env": "^1.13.6",
    "@typescript-eslint/eslint-plugin": "^2.x",
    "@typescript-eslint/parser": "^2.x",
    "babel-preset-taro": "3.0.0-rc.6",
    "eslint": "^6.8.0",
    "eslint-config-taro": "3.0.0-rc.6",
    "eslint-plugin-import": "^2.12.0",
    "eslint-plugin-react": "^7.8.2",
    "eslint-plugin-react-hooks": "^1.6.1",
    "stylelint": "9.3.0",
    "typescript": "^3.7.0"
  }
}
taro-ui-bot[bot] commented 4 years ago

欢迎提交 Issue~

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

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

Good luck and happy coding~

zhangdongsh commented 4 years ago

+1,引用层级明显不对吧,直接按官方文档初始化项目,然后引用taro-ui就挂了

pandaXiong01 commented 4 years ago

taroUI正式版的不支持taro3.0

TechQuery commented 4 years ago

看这里 https://github.com/NervJS/taro-ui/issues/947#issuecomment-654712315

349989153 commented 4 years ago

@TechQuery 谢了兄弟,解决了。