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 convert 出现的error: slot 的值必须是一个字符串 #2291

Closed
7zf001 opened this issue Feb 28, 2019 · 6 comments
Closed

taro convert 出现的error: slot 的值必须是一个字符串 #2291

7zf001 opened this issue Feb 28, 2019 · 6 comments
Labels
question Further information is requested

Comments

@7zf001
Copy link

7zf001 commented Feb 28, 2019

问题描述
我需要for循环来在组件中的slot添加内容。

复现步骤

  1. 创建组件
//  /components/tabs/index.js
Component({
  options: {
    multipleSlots: true
  }
})
//  /components/tabs/index.wxml
<view>
组件:
start:
<view
  wx:for="{{ 5 }}" 
  wx:key="*this"
>
  <slot name="{{ ‘’ + index }}"></slot>
</view>
end:
</view>
  1. 创建page
// index.wxml
<view>
  page页面:
  <tabs>
     <view 
      wx:for="{{ 5 }}" 
      wx:key="*this" 
      slot="{{ ‘’ + index }}"
    >
      {{ index }}
    </view>
  </tabs>
</view>
// index.json
{
  "usingComponents": {
    "tabs": "/Components/tabs/index"
  }
}
  1. taro convert时:
    错误 页面转换 pages/index/index.js
    Error: slot 的值必须是一个字符串

期望行为
不报错

报错信息
tanzhifengdeMacBook-Pro:test tanzhifeng$ taro convert
👽 Taro v1.2.15

开始代码转换...
转换 入口文件 app.js
转换 入口配置 app.json
转换 入口样式 app.wxss
生成 入口文件 taroConvert/src/app.js
转换 页面文件 pages/index/index.js
转换 页面配置 pages/index/index.json
转换 页面模板 pages/index/index.wxml
转换 页面样式 pages/index/index.wxss
错误 页面转换 pages/index/index.js
Error: slot 的值必须是一个字符串

@taro-bot
Copy link

taro-bot bot commented Feb 28, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@yuche
Copy link
Contributor

yuche commented Feb 28, 2019

如报错所言,Taro 转小程序是没有办法使用动态的 slot 名的,你只能更改你的实现逻辑了

@yuche yuche added question Further information is requested resolved labels Feb 28, 2019
@taro-bot
Copy link

taro-bot bot commented Feb 28, 2019

Hello~

您的问题楼上已经提供了解决方案,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

如果您在这 15 天中更新更多信息自动关闭的流程会自动取消,如有其他问题也可以发起新的 Issue。

Good luck and happy coding~

@7zf001
Copy link
Author

7zf001 commented Feb 28, 2019

@yuche 后期版本会支持吗?还是编译上无法实现?

@yuche
Copy link
Contributor

yuche commented Feb 28, 2019

编译上无法实现,编译到 jsx 一定要有名字,而且这个名字一定不能是动态生成的。

@7zf001
Copy link
Author

7zf001 commented Feb 28, 2019

@yuche 明白,谢谢啦

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants