【发布时间】:2021-01-14 09:51:55
【问题描述】:
<template>
<div>
<table class="table table-responsive">
<tbody>
<tr v-for="(gameresults, index) in gameresults" :key="index">
<td style="color: #082ad4; font-size: 24px;">{{ gameresults.game_name }}</br>
<h3 style="color:#00d2f1; font-size: 18px;">{{ gameresults.cards }}</h3></td>
<h3 style="color:#00d2f1; font-size: 18px;">{{ this.formattedArray }}</h3></td>
</tr>
</tbody>
</table>
</div></template>
<script>
export default {
props: [''],
mounted() {
console.log('Component mounted.')
},
data() {
return {
gameresults:0,
};
},
methods: {
changeResult() {
let formattedArray = [];
this.gameresults.cards.forEach(str => {
const subs = str.split('');
const subsTwo = subs[2].split(',');
const formattedString = `${subs[1]} - ${subs[0]}-${subsTwo[0]}${subs[4]}-${subsTwo[1]}`;
formattedArray.push(formattedString);
});
console.log('Formatted Data', formattedArray);
}
// this.gameresults[0].cards
},
computed: {
chkgameresults() {
axios.post('/gameresults')
.then(response => {
this.gameresults = response.data ;
this.changeResult();
});
},
},
created () {
this.chkgameresults();
}
};
</script>
ref code axios 以数组格式获取 mysql concat 数据,具有 2 个键 [game_name 和 card] 我希望对卡键进行操作。当我使用 this.gameresults[0].card 打印卡片数组时,它给我 123-9,897-0 使用 {{ gameresults.cards }} 在 vu 模板中,我希望值像 123-90-897 一样被操纵(只有最后一个 0在第二个 exp 之前获取并变为 0-897 删除 ',' 分隔符
【问题讨论】:
-
我只需要操作最后 4 个数字以相反的顺序打印 {{ mydata.myvalue }} 122-5,147-2 应该打印如下 122-5,2-147
-
Mydata.myvalue....这是一个数组吗?
-
不,它不是数组,它位于一个数据字段中
-
那你只需要使用NLP