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

使用 vant-weapp UI 库,编译后 van-dropdown-menu 组件缺少依赖项 #5198

Closed
KuangPF opened this issue Dec 26, 2019 · 4 comments
Closed
Assignees

Comments

@KuangPF
Copy link
Contributor

KuangPF commented Dec 26, 2019

问题描述

使用 vant-weappvan-dropdown-menu 以及 van-dropdown-item 组件时,抛出以下错误:
WX20191226-232117@2x
使用代码:

class VantWeapp extends PureComponent {
  state = {
    menuDropList: [{ text: '全部商品', value: 0 }, { text: '新款商品', value: 1 }, { text: '活动商品', value: 2 }],
    menuDropValue: 0
  }
  config: Config = {
    usingComponents: {
      'van-dropdown-menu': '/components/vant-weapp/dist/dropdown-menu/index',
      'van-dropdown-item': '/components/vant-weapp/dist/dropdown-item/index'
    }
  }
  render() {
    const { menuDropList, menuDropValue } = this.state
    return (
      <View className="custom-class demo-block van-clearfix demo-block--padding">
        <van-dropdown-menu>
            <van-dropdown-item value={menuDropValue} options={menuDropList} />
          </van-dropdown-menu>
      </View>
    )
  }
}

export default VantWeapp

查看 vant-weapp 源文件文件,代码如下:

// dropdown-menu/index.wxml
<wxs src="../wxs/utils.wxs" module="utils" />
<wxs src="./index.wxs" module="computed" />

<view class="van-dropdown-menu van-dropdown-menu--top-bottom">
  // some code ...
</view>

van-dropdown-menu 对应目录结构如下:
lE0HfO.md.png

查看 tao 编译后的代码如下:
lEBUN6.md.png
发现编译后没有 index.wsx,因此出现以上错误。

复现步骤

如上

系统信息

Taro CLI 1.3.29 environment info:
    System:
      OS: macOS 10.15.1
      Shell: 5.7.1 - /bin/zsh
    Binaries:
      Node: 10.5.0 - ~/.nvm/versions/node/v10.5.0/bin/node
      Yarn: 1.12.3 - /usr/local/bin/yarn
      npm: 6.1.0 - ~/.nvm/versions/node/v10.5.0/bin/npm
@taro-bot
Copy link

taro-bot bot commented Dec 26, 2019

CC @Chen-jj

@taro-bot
Copy link

taro-bot bot commented Dec 26, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@luckyadam
Copy link
Member

https://nervjs.github.io/taro/docs/config-detail.html#copy
手工配置一下 copy,把缺失的 wxs 文件 copy 过去吧

@GreatAuk
Copy link

GreatAuk commented Aug 7, 2020

因为 index.wxs 这个后缀的文件没有自动 copy 过去,需求手动添加配置:

    patterns: [
      ...
      {
        from: 'src/components/vant-weapp/calendar/',
        to: 'dist/components/vant-weapp/calendar/'
      }
    ],

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

4 participants