vue开发中如何实现select
下拉框异步传值,下面编程教程网小编给大家简单介绍一下!
具体代码如下:
<template>
<select v-model="selectValue">
<option v-for="(item,index) in selectOptions" :value="item.id">{{ item.name }}</option>
</select>
</template>
<script>
import axios from "axios";
export default {
data() {
return {
selectValue: null,
selectOptions: []
};
},
mounted() {
axios
.get("http://example.com/test")
.then(res => {
this.selectOptions = res.data;
})
.catch(error => {
console.log(error);
});
}
};
</script>
以上是编程学习网小编为您介绍的“vue如何实现select下拉框异步传值”的全面内容,想了解更多关于 vuejs 内容,请继续关注编程基础学习网。
沃梦达教程
本文标题为:vue如何实现select下拉框异步传值


猜你喜欢
- 浏览器加载、渲染和解析过程黑箱简析 2023-12-25
- layui实现根据table数据判断按钮显示情况的方法 2024-12-13
- 小程序页面间传参的五种方式实例详解 2022-08-30
- webpack 如何解析代码模块路径的实现 2024-01-14
- css3实现模糊背景,内容清晰 2024-12-14
- shell-script – 用于反转HTML文件中数千个元素的排序顺序的正确工具 2023-10-25
- onkeypress字符按键兼容所有浏览器使用介绍 2023-12-01
- 详解CSS样式中的!important、*、_符号 2022-11-13
- google地图的路线实现代码 2023-12-25
- ztree+ajax实现文件树下载功能 2023-02-23