javascript - 在 vue.js 中执行 axios.get 时捕获特定元素
问题描述
在点击 URL 时执行 axios.get 调用时,我想捕获一个元素并将其分配给 lastid -“ http://127.0.0.1:5000/api/products/ ”。我不知道如何捕获一个单一的元素,即“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>
解决方案
推荐阅读
- python - 如何在python中将Json标签拆分为数据框
- java - Mpandroid图表库饼图点击事件
- reactjs - 从 React 应用程序向 Rocket 后端发送 POST 请求时出错返回失败
- view - 在 SwiftUI 中呈现视图控制器
- python - 为什么通过抓取 LinkedIn 它无法加载请求的 url?Python
- dropwizard - Dropwizard配置与环境变量中的字符串列表与默认后备?
- r - 试图改进我的代码 - 多列的布尔运算 - 数据框
- influxdb - 使用电报输入插件解析 JSON 文件:意外输出
- eclipse - Tomcat 和 Eclipse 与 Intellij
- c++ - what(): basic_string::_M_construct null 无效