Skip to content

在vue或者react里面,应该如何使用qrcode #6

@Fairfarren

Description

@Fairfarren

我当前的一个项目是用react写的,有一个功能是识别图片中的二维码

我使用import '../static/qrcode.lib.min'这种方式引入到组件中,会报错

于是我选择了<script src="qrcode.lib.min.js"></script>标签的方式去引入

然后我在组件的componentDidMount方法中去初始化,会提示$ undefined

最后我选择了在index.html页面中去初始化,并且使用了onhashchange方法去监听路由的变化,不监听的话会因为路由的变化导致不能调出选择图片的方法

虽然这种方法比较笨,但是能解决

我想问问在react或者vue里面,有没有更优的做法?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions