<template> <view> <image :src="mySrc" style="width: 100%;"></image> <view class="show"> <button type="primary" @click="selectimg()">请上传户口本页面</button> </view> <view> <uni-section title="姓名" type="line"> <uni-card :is-shadow="false"> <text class="uni-body">{{personname}}</text> </uni-card> </uni-section> <uni-section title="身份证号" type="line"> <uni-card :is-shadow="false"> <text class="uni-body">6105******</text> </uni-card> </uni-section> <uni-section title="评论区" type="line" padding> <uni-easyinput type="textarea" v-model="value" placeholder="请输入内容"></uni-easyinput> </uni-section> </view> <uni-section title="评论得分" type="line" padding> <uni-rate v-model="rateValue" @change="onChange" /> </uni-section> <view> <button type="primary">确定评论</button> </view> </view> </template> <script> export default { data() { return { mySrc: require("@/static/logo/lo3.png"), personname:"", }; }, methods: { selectimg() { uni.chooseImage({ count: 1, sizeType: ['original', 'compressed'], sourceType: ['album'], success: (res) => { console.log(res.tempFilePaths[0]); this.mySrc = res.tempFilePaths[0]; this.changeImgToBase64(res.tempFilePaths[0]); } }); }, changeImgToBase64(source_img) { uni.getFileSystemManager().readFile({ filePath: source_img, encoding: "base64", success: (res) => { console.log("加密之后的图片格式:" + JSON.stringify(res)); this.makeFinalResult(res.data); }, }); }, async makeFinalResult(base64) { let token = await uni.request({ url: 'https://aip.baidubce.com/oauth/2.0/token', data: { grant_type: 'client_credentials', client_id: '2kKeVk6LvdFX8knIyYUodMDr', client_secret: '9pSXGfzvv7q1Fo76WRkeyXVpZGrj8zxb', }, success: (res) => { console.log("获取token:===>" + res.data.access_token); token = res.data.access_token; }, }); uni.request({ url: 'https://aip.baidubce.com/rest/2.0/ocr/v1/household_register?access_token=' + token, method: 'POST', data: { image: base64, }, header: { "Content-Type": "application/x-www-form-urlencoded", }, success: (res) => { console.log("最终的结果:" + JSON.stringify(res)); //this.personname = res.words_result.Name.words; }, }); }, }, }; </script> <style lang="scss"> .show { display: flex; justify-content: center; height: 100vh; align-items: center; } <style>
时间: 2024-01-03 16:36:46 浏览: 35
这是一个Vue.js组件的代码,用于上传图片并进行文字识别。代码中包含了以下主要部分:
1. 模板部分:使用了Vue.js的模板语法,定义了一个视图,包含一个图片元素、一个显示区域、一些文本和按钮等。
2. 数据部分:通过data()方法定义了组件的数据属性,包括mySrc(图片路径)和personname(姓名)等。
3. 方法部分:定义了selectimg()方法,用于选择图片并显示在页面上;changeImgToBase64()方法,将选择的图片转换为base64格式;makeFinalResult()方法,通过调用百度OCR接口进行图片识别,并将识别结果赋值给personname属性。
4. 样式部分:使用了scss语法定义了一些样式。
需要注意的是,该代码中的请求地址、密钥等可能是测试用的,实际使用时需要替换为真实的接口地址和密钥。
相关问题
QT += core gui sql network greaterThan(QT_MAJOR_VERSION, 4): QT += widgets CONFIG += c++11 # The following define makes your compiler emit warnings if you use # any Qt feature that has been marked deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if it uses deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 SOURCES += \ chatinterface.cpp \ main.cpp \ myapp.cpp \ myenroll.cpp \ mylogin.cpp \ sqoperator.cpp \ tips.cpp HEADERS += \ chatinterface.h \ myapp.h \ myenroll.h \ mylogin.h \ sqoperator.h \ tips.h # Default rules for deployment. qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target RESOURCES += \ mysrc.qrc \ mysrc.qrc \ mysrc.qrc \ mysrc.qrc \ mysrc.qrc DISTFILES += \解释qt的每行工程文件
这是一个Qt工程文件,包含以下内容:
1. `QT += core gui sql network`:指定需要使用的Qt模块,包括核心、GUI、SQL和网络模块。
2. `greaterThan(QT_MAJOR_VERSION, 4): QT += widgets`:如果Qt的主版本号大于4,则添加widgets模块。
3. `CONFIG += c++11`:使用C++11标准编译工程。
4. `DEFINES += QT_DEPRECATED_WARNINGS`:定义QT_DEPRECATED_WARNINGS,使编译器在使用已被标记为已弃用的Qt特性时发出警告。
5. `SOURCES`和`HEADERS`:指定源文件和头文件,包括chatinterface.cpp、main.cpp、myapp.cpp、myenroll.cpp、mylogin.cpp、sqoperator.cpp、tips.cpp、chatinterface.h、myapp.h、myenroll.h、mylogin.h、sqoperator.h和tips.h。
6. `qnx: target.path = /tmp/$${TARGET}/bin else: unix:!android: target.path = /opt/$${TARGET}/bin !isEmpty(target.path): INSTALLS += target`:为不同的部署平台指定安装路径。
7. `RESOURCES`:指定资源文件,包括mysrc.qrc。
8. `DISTFILES`:指定分发的文件。
Failed to compile. ./src/views/Kanban/drugDistribution/index.vue?vue&type=script&lang=js& (./node_modules/babel-loader/lib?cacheDirectory!./node_modules/vue-loader/lib??vue-loader-options!./src/views/Kanban/drugDistribution/index.vue?vue&type=script&lang=js&) Module not found: Error: Can't resolve './dataVisualization' in 'D:\公司项目最新\mysrc\visit-user\src\views\Kanban\drugDistribution'
这似乎是一个编译错误,指出在路径 `./dataVisualization` 中找不到模块。可能是由于以下原因之一:
1. 模块确实不存在于指定的路径中。
2. 路径不正确,导致模块无法找到。
3. 模块存在,但未正确安装或导入。
您可以先检查路径是否正确,如果路径正确,可以尝试重新安装依赖项,或者检查导入语句是否正确。如果问题仍然存在,请提供更多信息,以便我可以更好地帮助您解决问题。