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

Upload 组件的onPreview有时候没法点击 #2163

Closed
revier opened this issue Jun 24, 2016 · 2 comments
Closed

Upload 组件的onPreview有时候没法点击 #2163

revier opened this issue Jun 24, 2016 · 2 comments

Comments

@revier
Copy link

revier commented Jun 24, 2016

看了下代码。

_this3.props.listType === 'picture-card' && file.status !== 'uploading' ? _react2["default"].createElement(
            'span',
            null,
            _react2["default"].createElement(
              'a',
              {
                onClick: function onClick(e) {
                  return _this3.handlePreview(file, e);
                },
                href: file.url,
                target: '_blank',
                style: { pointerEvents: file.url ? '' : 'none' }
              },
              _react2["default"].createElement(_icon2["default"], { type: 'eye-o' })
            ),
            _react2["default"].createElement(_icon2["default"], { type: 'delete', onClick: function onClick() {
                return _this3.handleClose(file);
              } })
          ) : _react2["default"].createElement(_icon2["default"], { type: 'cross', onClick: function onClick() {
              return _this3.handleClose(file);
            } })
        )

style的属性那边表示,如果file没有url的时候,就没法点击。

而我的组件代码如下

 <FormItem
          {...formItemLayout}
          label="添加图片">
          <Upload 
              action={upload_url}
              listType="picture-card"
              fileList={this.props.fileList}
              onChange={this.handleLogoUpload.bind(this)}
              onPreview={this.props.setPreview}
              onRemove={this.props.handleRemove}>
              <Icon type="upload" /> 点击上传
          </Upload>
           <Modal visible={this.props.previewVisible} footer={null} onCancel={this.props.handleCancel} >
                <img alt="example" src={this.props.task.thumbnail}/>
          </Modal>
        </FormItem>

上传图片成功后返回的file里面没有url这个属性。所以就没法点击了。
而我在手动给file添加了url这个属性的值后,就可以点击了。

这种实现感觉比较奇怪,也导致出问题很难debug。
请考虑一下。

@revier revier changed the title Upload 组建的onPreview有时候不好使 Upload 组件的onPreview有时候没法点击 Jun 24, 2016
@afc163 afc163 closed this as completed Jun 24, 2016
@aw6658913
Copy link

我觉得如果要出现缩略图,那么不一定有url但一定有thumbUrl这属性,可以把
style: { pointerEvents: file.url ? '' : 'none' }
修改为:
style: { pointerEvents: file.thumbUrl ? '' : 'none' }
就省事多了~

@lock
Copy link

lock bot commented May 5, 2018

This thread has been automatically locked because it has not had recent activity. Please open a new issue for related bugs and link to relevant comments in this thread.

@lock lock bot locked as resolved and limited conversation to collaborators May 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants