javascript - 将 vue.js 中的结果附加到基于语义 UI 的模板
问题描述
我正在努力添加“加载更多”,这将在当前页面中加载更多随机产品。我的问题是它没有附加,而是更改了用户将单击“加载更多”的当前值。单击“加载更多”时,如何在不更改先前值的情况下附加值。
<div class="ui six doubling cards" id="app-5">
<div class="card" v-for="i in message">
<div class="image">
<img v-bind:src="[[ i.ImageURL ]]">
<div class="ui top right attached red label">[[i.OfferPercentage]]% OFF</div>
</div>
<div class="content">
<a v-bind:href="[[i.ProductURL]]" target="_blank">
<div class="ui container">
<div class="ui tiny blue header"> [[i.ProductName]]</div>
<h5 class="ui grey header">[[i.Category]]</h5>
<h5 class="ui red header">₹[[i.ActualPrice]] <s>₹[[i.StrikedPrice]]</s> </h5>
</div>
</a>
</div>
</div>
<button v-on:click="reverseMessage" class="fluid ui button">Load More</button>
</div>
<p></p>
<script>
var app5 = new Vue({
el: '#app-5',
delimiters: ['[[',']]'],
data: {
message: []
},
methods: {
reverseMessage: function () {
axios.get('http://127.0.0.1:5000/test').then(response => {
this.message = response.data;
});
}
}
});
</script>
解决方案
而不是替换this.message
,附加到它:
axios.get('http://127.0.0.1:5000/test').then(response => {
this.message.push(...response.data);
});
推荐阅读
- google-bigquery - 从 Google BigQuery 中的 select 语句创建或更新表
- activemq - 如何取消确认消息并将其发送回 ActiveMQ 中的队列?
- python - 在 training_test 拆分或原始数据集之后进行引导?
- javascript - 如何解决 React 中的 API 获取和类型错误
- swift - “错误域 = NSCocoaErrorDomain 代码 = 3840 “字符 0 周围的值无效。”使用从 Date() 转换的字符串时
- arrays - 循环 fscanf 内的错误分配
- r - 数据框中跨列的变量值计数
- highcharts - Highcharts 中的实时图表使线系列非常...多山
- linux - 用于在 txt 文件中移动数字的 Bash 脚本
- python - 为什么 asyncio.CancelledError 需要重新提出?