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

alipay下:reducers暴露时命名为‘location’,编译报错 #2677

Closed
zengtv opened this issue Apr 3, 2019 · 5 comments
Closed

alipay下:reducers暴露时命名为‘location’,编译报错 #2677

zengtv opened this issue Apr 3, 2019 · 5 comments
Assignees
Labels
question Further information is requested

Comments

@zengtv
Copy link

zengtv commented Apr 3, 2019

Feature Request 请提到 FeatHub

如果是提交 bug,请搜索文档和 issue,确认以下事项:

  • 该问题没有在其他 issue 和文档讨论到,不属于重复内容

  • 分割线以下的模板除了「 补充信息」每一样都必填

如果不满足以上两点要求的 bug 报告,issue 会被直接关掉。

请多多理解,您现在的不便将会使 Taro 开发者更高效地定位你的问题,修复你的问题。像你一样的 Taro 的使用者也可以通过搜索找到你提供的 bug,对各方都有很大好处。

🙏🙏🙏
阅读完后请在提交的issue中删除以上内容,包括分割线。

问题描述
[问题描述:站在其它人的角度尽可能清晰地、简洁地把问题描述清楚]
reducers文件不能暴露名为location的函数

复现步骤
[复现问题的步骤]
Taro init redux 模板 =>
src/reducers/counter.js 把暴露的函数名counter更改为location =>
npm run dev:alipay =>
No reducer provided for key "counter"

[或者可以直接贴源代码,能贴文字就不要截图]

// 这里可以贴代码
import { ADD, MINUS } from '../constants/counter'

const INITIAL_STATE = {
  num: 0
}

export default function location (state = INITIAL_STATE, action) {
  switch (action.type) {
    case ADD:
      return {
        ...state,
        num: state.num + 1
      }
     case MINUS:
       return {
         ...state,
         num: state.num - 1
       }
     default:
       return state
  }
}

期望行为
[这里请用简洁清晰的语言描述你期望的行为]
正常编译
报错信息
No reducer provided for key "counter"
[这里请贴上你的完整报错截图或文字]
image

系统信息

Taro v1.2 及以上版本已添加 taro info 命令,方便大家查看系统及依赖信息,运行该命令后将结果贴下面即可。
Taro CLI 1.2.21 environment info:
System:
OS: Windows 10
Binaries:
Node: 10.15.3 - D:\Program Files\nodejs\node.EXE
Yarn: 1.15.2 - D:\Program Files\Yarn\bin\yarn.CMD
npm: 6.4.1 - D:\Program Files\nodejs\npm.CMD

报错平台 : alipay
补充信息
[可选]
[根据你的调查研究,出现这个问题的原因可能在哪里?]

@taro-bot
Copy link

taro-bot bot commented Apr 3, 2019

欢迎提交 Issue~

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

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

Good luck and happy coding~

@Garfield550
Copy link
Collaborator

image

import counter from './counter'

你 import 的名字改了吗?

@zengtv
Copy link
Author

zengtv commented Apr 3, 2019

image

taro/packages/taro-cli/templates/redux/reducers/indexjs

Line 2 in 48a1e3c

import counter from './counter'
你 import 的名字改了吗?

因为是export default ,所以在import的时候可以是任意名。事实上只要不是‘location’这个单词,把counter改成任意名,其他地方不动,都可以编译成功

@Chen-jj Chen-jj self-assigned this Apr 4, 2019
@Chen-jj
Copy link
Contributor

Chen-jj commented Apr 4, 2019

@zengtv 支付宝不支持 export 命名为 location 的变量,已反馈给他们了,可以先取其它名字代替。

@Chen-jj Chen-jj added question Further information is requested answered labels Apr 4, 2019
@taro-bot taro-bot bot added the to be closed label Apr 4, 2019
@taro-bot
Copy link

taro-bot bot commented Apr 4, 2019

Hello~

您的问题楼上已经有了确切的回答,如果没有更多的问题这个 issue 将在 15 天后被自动关闭。

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

Good luck and happy coding~

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

3 participants