<template>
<div class="container">
<Area v-on:setImgSrc="setImgSrc"/>
<textarea v-model="value"></textarea>
</div>
</template>
<script>
import Area from "@/views/until/BaseView";
import axios from "axios";
export default {
components: {
Area
},
data: function() {
return {
value: '',
}
},
methods: {
setImgSrc: function (value) {
this.value = value;
// console.log(this.value)
var imgArr = [];
var that = this;
var str = '';
// var str1 = '';
str = that.value;
imgArr = str.split(',');
// 切割的部分
// str1 = imgArr[1];
// console.log(typeof str1);
//
console.log(typeof imgArr[1]);
axios.post('http://localhost:9090/text/text-only',{
imgBase64: imgArr[1],
imgType: 'png' }).then(function(res){
that.resdata = res.data;
that.resdata.forEach((v)=>{
that.str = that.str + v.text
})
console.log(that.str)
});
// str = imgArr[1]
// console.log(imgArr[1])
// 切割写法
// console.log(str);
// axios.post('http://localhost:9090/text/text-only',{
// imgBase64: ,
// imgType: 'png' }).then(function(res){
// that.resdata = res.data;
// that.resdata.forEach((v)=>{
// that.str = that.str + v.text
// })
// console.log(that.str)
// })
// }
}
}
}
</script>
<style>
textarea {
display: block;
height: 200px;
max-width: 100%;
min-width: 100%;
padding: calc(0.75em - 1px);
resize: vertical;
box-shadow: inset 0 0.0625em 0.125em rgba(10, 10, 10, 0.05);
width: 100%;
background-color: #fff;
border-color: #dbdbdb;
border-radius: 4px;
box-sizing: border-box;
}
</style>