vue3如何将异步获取的后端返回值在前端页面显示?
methods: {async searchLocation() {
try {
const response = await axios.get('http://localhost:29999/selectLocationByNumber/'+this.inputValue);
console.log(response.data);
this.number = response.data.number;
this.location = response.data.location;
} catch (error) {
// 处理请求错误
console.error('Error fetching data:', error);
}
},}
<script>export default {data() {
return {number:'',
location:'',}
}}
</script>
<el-table>
<el-table-column label="号码">{{ number }}</el-table-column>
<el-table-column label="所属运营商">{{ location }}</el-table-column>
</el-table>
异步方法向后端发送请求,得到返回值response,number和location在页面上显示不出来?不会vue
回复
1个回答
test
2024-06-26
<el-table>
不是这么用的 给你文档,你自己看下http://element-plus.org/zh-CN/component/table.html#%E5%9F%BA%...
回复
适合作为回答的
- 经过验证的有效解决办法
- 自己的经验指引,对解决问题有帮助
- 遵循 Markdown 语法排版,代码语义正确
不该作为回答的
- 询问内容细节或回复楼层
- 与题目无关的内容
- “赞”“顶”“同问”“看手册”“解决了没”等毫无意义的内容