【发布时间】:2017-10-29 06:35:50
【问题描述】:
假设我有一个这样的反应组件:
class App extends Component {
print = () => {
const { url } = this.props
const frame = document.createElement('iframe')
frame.addEventListener('load', () => {
const win = frame.contentWindow
win.focus()
win.print()
win.addEventListener('focus', () => document.body.removeChild(frame))
})
Object.assign(frame.style, {
visibility: 'hidden',
position: 'fixed',
right: 0,
bottom: 0
})
frame.src = url
document.body.appendChild(frame)
}
}
基本上,单击按钮会为用户调用浏览器中的打印功能。在这种情况下,我是否仍然将其变成像 DO_PRINT 这样的 redux 操作,它实际上对我的 redux 状态没有任何作用,还是我只是不理会它?
【问题讨论】:
标签: javascript reactjs redux action