当点击URL-“ http://127.0.0.1:5000/api/products/”时执行axios.get调用时,我想捕获一个元素并将其分配给lastid。我不知道如何一次捕获到一个单独的元素,即“ ldd”(如JSON格式所示)并将其分配给vue.js脚本lastid变量。
[
{
"ActualPrice": 275,
"Category": "Beauty",
"ImageURL": "https://beautyme.jpg",
"OfferPercentage": 50,
"ProductName": "Fogg Deo",
"ProductURL": "https://nico.com",
"StrikedPrice": 550,
"ldd": "5bdd04934d395947f9c04237"
},
{
"ActualPrice": 229,
"Category": "Beauty",
"ImageURL": "https://beautyme.jpg",
"OfferPercentage": 50,
"ProductName": "Marco, 150ml (Pack of 2)",
"ProductURL": "https://nico.com",
"StrikedPrice": 460,
"ldd": "5bdd04934d395947f9c04237"
},
]
<script>
var app5 = new Vue({
el: '#app-5',
delimiters: ['[[',']]'],
data: {
message: [],
ld: 0,
},
methods: {
loadmore: function () {
axios.get('http://127.0.0.1:5000/api/products/'+ld)
.then(response => {
this.message.push(...response.data);
lastid = "5bdd04934d395947f9c04237"; //I want to update lastid
});
}
},
});
</script>